diff --git a/CMakeLists.txt b/CMakeLists.txt index 014a67c9f8f3d46d5b0ab5a92a40cc447aa7a975..27caa7a2fb6a45dbcd81003854ca55b42a283b59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,7 +155,6 @@ set (NFAPI_USER_DIR ${OPENAIR_DIR}/nfapi/oai_integration) set (OPENAIR1_DIR ${OPENAIR_DIR}/openair1) set (OPENAIR2_DIR ${OPENAIR_DIR}/openair2) set (OPENAIR3_DIR ${OPENAIR_DIR}/openair3) -set (OPENAIR_TARGETS ${OPENAIR_DIR}/targets) set (OPENAIR3_DIR ${OPENAIR_DIR}/openair3) set (OPENAIR_CMAKE ${OPENAIR_DIR}/cmake_targets) set (OPENAIR_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}) @@ -342,7 +341,6 @@ add_boolean_option(DISABLE_XER_PRINT False "print XER Format") add_boolean_option(XER_PRINT False "print XER Format") add_boolean_option(DEBUG_PDCP_PAYLOAD False "print PDCP PDU to stdout") # if true, make sure that global and PDCP log levels are trace add_boolean_option(DEBUG_MAC_INTERFACE False "print MAC-RLC PDU exchange to stdout") # if true, make sure that global and PDCP log levels are trace -add_boolean_option(TRACE_RLC_PAYLOAD False "print RLC PDU to stdout") # if true, make sure that global and PDCP log levels are trace add_boolean_option(PRINT_STATS False "This adds the possibility to see the status") add_boolean_option(T_TRACER True "Activate the T tracer, a debugging/monitoring framework" ) add_boolean_option(UE_AUTOTEST_TRACE False "Activate UE autotest specific logs") @@ -720,31 +718,6 @@ add_boolean_option(NAS_UE True "NAS UE INSTANCE (<> NAS_MME)") ########################## add_boolean_option(JUMBO_FRAME True "ENABLE LARGE SDU in ACCESS STRATUM (larger than common MTU)") -########################## -# RLC LAYER OPTIONS -########################## -add_boolean_option(TRACE_RLC_PAYLOAD False "Fatal assert in this case") -add_boolean_option(RLC_STOP_ON_LOST_PDU False "Fatal assert in this case") - -add_boolean_option(TRACE_RLC_MUTEX True "TRACE for RLC, possible problem in thread scheduling") -add_boolean_option(TRACE_RLC_AM_BO False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_AM_FREE_SDU False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_AM_HOLE False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_AM_PDU False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_AM_RESEGMENT False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_AM_RX False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_AM_TX False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_AM_TX_STATUS False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_AM_STATUS_CREATION False "TRACE for RLC AM, TO BE CHANGED IN A MORE GENERAL FLAG") - -add_boolean_option(STOP_ON_IP_TRAFFIC_OVERLOAD False "") -add_boolean_option(TRACE_RLC_UM_DAR False "TRACE for RLC UM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_UM_DISPLAY_ASCII_DATA False "TRACE for RLC UM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_UM_PDU False "TRACE for RLC UM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_UM_RX False "TRACE for RLC UM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_UM_SEGMENT False "TRACE for RLC UM, TO BE CHANGED IN A MORE GENERAL FLAG") -add_boolean_option(TRACE_RLC_UM_TX_STATUS False "TRACE for RLC UM, TO BE CHANGED IN A MORE GENERAL FLAG") - ########################## # PDCP LAYER OPTIONS @@ -804,9 +777,6 @@ include_directories("${OPENAIR2_DIR}/ENB_APP") include_directories("${OPENAIR2_DIR}/GNB_APP") include_directories("${OPENAIR2_DIR}/MCE_APP") include_directories("${OPENAIR2_DIR}/LAYER2/RLC") -include_directories("${OPENAIR2_DIR}/LAYER2/RLC/AM_v9.3.0") -include_directories("${OPENAIR2_DIR}/LAYER2/RLC/UM_v9.3.0") -include_directories("${OPENAIR2_DIR}/LAYER2/RLC/TM_v9.3.0") include_directories("${OPENAIR2_DIR}/LAYER2/PDCP_v10.1.0") include_directories("${OPENAIR2_DIR}/RRC/LTE/MESSAGES") include_directories("${OPENAIR2_DIR}/RRC/LTE") @@ -831,7 +801,6 @@ include_directories("${OPENAIR2_DIR}/F1AP") include_directories("${OPENAIR3_DIR}/ocp-gtpu") include_directories("${OPENAIR3_DIR}/M3AP") include_directories("${OPENAIR3_DIR}/MME_APP") -include_directories("${OPENAIR_DIR}/targets/COMMON") include_directories("${OPENAIR_DIR}/radio/COMMON") include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/PHY") include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/MAC") @@ -864,8 +833,6 @@ add_library(HASHTABLE include_directories(${OPENAIR_DIR}/common/utils/hashtable) add_library(UTIL - ${OPENAIR2_DIR}/UTIL/LISTS/list.c - ${OPENAIR2_DIR}/UTIL/LISTS/list2.c ${OPENAIR_DIR}/common/utils/LOG/log.c ${OPENAIR_DIR}/common/utils/LOG/vcd_signal_dumper.c ${OPENAIR2_DIR}/UTIL/MATH/oml.c @@ -1409,45 +1376,11 @@ set(NR_UE_MAC_DIR ${OPENAIR2_DIR}/LAYER2/NR_MAC_UE) set(PHY_INTERFACE_DIR ${OPENAIR2_DIR}/PHY_INTERFACE) set(NR_PHY_INTERFACE_DIR ${OPENAIR2_DIR}/NR_PHY_INTERFACE) set(NR_UE_PHY_INTERFACE_DIR ${OPENAIR2_DIR}/NR_UE_PHY_INTERFACE) -set(RLC_DIR ${OPENAIR2_DIR}/LAYER2/RLC) -set(RLC_UM_DIR ${OPENAIR2_DIR}/LAYER2/RLC/UM_v9.3.0) -set(RLC_AM_DIR ${OPENAIR2_DIR}/LAYER2/RLC/AM_v9.3.0) -set(RLC_TM_DIR ${OPENAIR2_DIR}/LAYER2/RLC/TM_v9.3.0) set(RRC_DIR ${OPENAIR2_DIR}/RRC/LTE) set(NR_RRC_DIR ${OPENAIR2_DIR}/RRC/NR) set(NR_UE_RRC_DIR ${OPENAIR2_DIR}/RRC/NR_UE) set(PDCP_DIR ${OPENAIR2_DIR}/LAYER2/PDCP_v10.1.0) -set(RLC_V1 - ${RLC_AM_DIR}/rlc_am.c - ${RLC_AM_DIR}/rlc_am_init.c - ${RLC_AM_DIR}/rlc_am_timer_poll_retransmit.c - ${RLC_AM_DIR}/rlc_am_timer_reordering.c - ${RLC_AM_DIR}/rlc_am_timer_status_prohibit.c - ${RLC_AM_DIR}/rlc_am_segment.c - ${RLC_AM_DIR}/rlc_am_segments_holes.c - ${RLC_AM_DIR}/rlc_am_in_sdu.c - ${RLC_AM_DIR}/rlc_am_receiver.c - ${RLC_AM_DIR}/rlc_am_retransmit.c - ${RLC_AM_DIR}/rlc_am_windows.c - ${RLC_AM_DIR}/rlc_am_rx_list.c - ${RLC_AM_DIR}/rlc_am_reassembly.c - ${RLC_AM_DIR}/rlc_am_status_report.c - ${RLC_TM_DIR}/rlc_tm.c - ${RLC_TM_DIR}/rlc_tm_init.c - ${RLC_UM_DIR}/rlc_um.c - ${RLC_UM_DIR}/rlc_um_fsm.c - ${RLC_UM_DIR}/rlc_um_control_primitives.c - ${RLC_UM_DIR}/rlc_um_segment.c - ${RLC_UM_DIR}/rlc_um_reassembly.c - ${RLC_UM_DIR}/rlc_um_receiver.c - ${RLC_UM_DIR}/rlc_um_dar.c - ${RLC_DIR}/rlc_mac.c - ${RLC_DIR}/rlc.c - ${RLC_DIR}/rlc_rrc.c - ${RLC_DIR}/rlc_mpls.c - ) - set(RLC_V2 ${OPENAIR2_DIR}/LAYER2/rlc_v2/rlc_oai_api.c ${OPENAIR2_DIR}/LAYER2/rlc_v2/asn1_utils.c diff --git a/common/utils/var_array.h b/common/utils/var_array.h new file mode 100644 index 0000000000000000000000000000000000000000..1d6d43652c5fee2f980b2b97d7aad5a7c6a7c2d5 --- /dev/null +++ b/common/utils/var_array.h @@ -0,0 +1,74 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + + +/*! \file var_array.c +* \brief Very primitive variable length array ds. Here for compatibility +* reasons, should be replaced with a more capable data structure. +* @ingroup util +*/ + +#ifndef VAR_ARRAY_H_ +#define VAR_ARRAY_H_ + +#include <stdlib.h> +#include "common/utils/assertions.h" + +typedef struct { + size_t size; + size_t mallocedSize; + size_t atomSize; + size_t increment; +} varArray_t; + +static inline varArray_t *initVarArray(size_t increment, size_t atomSize) +{ + varArray_t *tmp = malloc(sizeof(*tmp) + increment * atomSize); + tmp->size = 0; + tmp->atomSize = atomSize; + tmp->mallocedSize = increment; + tmp->increment = increment; + return tmp; +} + +static inline void *dataArray(varArray_t *input) +{ + return input + 1; +} + +static inline void appendVarArray(varArray_t **inputPtr, void *data) +{ + varArray_t *input = *inputPtr; + if (input->size >= input->mallocedSize) { + input->mallocedSize += input->increment; + *inputPtr = realloc(input, sizeof(varArray_t) + input->mallocedSize * input->atomSize); + AssertFatal(*inputPtr, "no memory left"); + input = *inputPtr; + } + memcpy((uint8_t *)(input + 1) + input->atomSize * input->size++, data, input->atomSize); +} + +static inline void freeVarArray(varArray_t *input) +{ + free(input); +} + +#endif /* VAR_ARRAY_H_ */ diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 0002981f78594680523cfc42302a30d7dfaec8a6..c4ff82c22becfeda6531541cdc992a25a68c60c5 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -37,6 +37,7 @@ #include <signal.h> #include "common/config/config_load_configmodule.h" #include "common/utils/LOG/log.h" +#include "common/utils/var_array.h" #include "nfapi/oai_integration/vendor_ext.h" #include "PHY/types.h" #include "PHY/defs_eNB.h" @@ -52,7 +53,6 @@ #include "SCHED/sched_eNB.h" #include "SCHED_UE/sched_UE.h" #include "SIMULATION/TOOLS/sim.h" -#include "UTIL/LISTS/list.h" #include "OCG_vars.h" #include "unitary_defs.h" #include "dummy_functions.c" diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index 27a8722ea57d6981c01493d65728c21fee8dbdf6..c03d081387d0d5078c82fc4a69f5a198c14d607c 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -33,6 +33,7 @@ #include <string.h> #include <math.h> #include <unistd.h> +#include "common/utils/var_array.h" #include "PHY/types.h" #include "PHY/defs_common.h" #include "PHY/defs_eNB.h" diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 134174e7cf01b3bc4097ee7d9b98c54c50a24330..2dc5b06dc97d6d2f34c21af00afd65f8ffb44af8 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -28,6 +28,7 @@ #include "common/ran_context.h" #include "common/config/config_userapi.h" #include "common/utils/nr/nr_common.h" +#include "common/utils/var_array.h" #include "common/utils/LOG/log.h" #include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h" #include "LAYER2/NR_MAC_UE/mac_defs.h" @@ -81,7 +82,6 @@ const char *__asan_default_options() } LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC; -rlc_info_t Rlc_info_um,Rlc_info_am_config; PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index fd145c568f56b0b8bf151e1d2fc7bcffd2a4a6f9..f0ac0369260b086cb2a630a0fc0501b4dbe1d744 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -59,7 +59,6 @@ #define PRACH_WRITE_OUTPUT_DEBUG 1 LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC; -rlc_info_t Rlc_info_um,Rlc_info_am_config; char *uecap_file; PHY_VARS_gNB *gNB; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 210b33774e9733f33f581b8caa07002a719a87e0..11c131a5c2b1e40a77351ff0c6c6e9ecc1edff55 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -29,6 +29,7 @@ #include "common/config/config_userapi.h" #include "common/utils/LOG/log.h" #include "common/utils/nr/nr_common.h" +#include "common/utils/var_array.h" #include "PHY/defs_gNB.h" #include "PHY/defs_nr_common.h" #include "PHY/defs_nr_UE.h" @@ -76,7 +77,6 @@ const char *__asan_default_options() } LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC; -rlc_info_t Rlc_info_um,Rlc_info_am_config; PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c index e2ec1567bea5271de823433a740c96cb90e56fa3..3213143db9f3c4221c96a1ef83efae5920a70792 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c @@ -130,7 +130,6 @@ int dl_rrc_message_rrcSetup(module_id_t module_id, const f1ap_dl_rrc_message_t * ue_context_p->ue_context.SRB_configList, NULL, NULL, - NULL, cellGroup->rlc_BearerToAddModList); return 0; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c deleted file mode 100644 index aed00e578a3bccdecd98ac0200f9c309c8ff9d6b..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ /dev/null @@ -1,948 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_C 1 -//----------------------------------------------------------------------------- -#include "platform_types.h" -#include "common/platform_constants.h" -//----------------------------------------------------------------------------- - -#include "assertions.h" -#include "hashtable.h" -#include "rlc_am.h" -#include "rlc_am_segment.h" -#include "rlc_am_timer_poll_retransmit.h" -#include "mac_primitives.h" -#include "rlc_primitives.h" -#include "list.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" -#include "LTE_UL-AM-RLC.h" -#include "LTE_DL-AM-RLC.h" - -//----------------------------------------------------------------------------- -uint32_t -rlc_am_get_status_pdu_buffer_occupancy( - rlc_am_entity_t *const rlc_pP) { - //Compute Max Status PDU size according to what has been received and not received in the window [vrR vrMS[ - // minimum header size in bits to be transmitted: D/C + CPT + ACK_SN + E1 - uint32_t nb_bits_to_transmit = RLC_AM_PDU_D_C_BITS + RLC_AM_STATUS_PDU_CPT_LENGTH + RLC_AM_SN_BITS + RLC_AM_PDU_E_BITS; - mem_block_t *cursor_p = rlc_pP->receiver_buffer.head; - rlc_am_pdu_info_t *pdu_info_cursor_p = NULL; - int waited_so = 0; - rlc_sn_t sn_cursor = rlc_pP->vr_r; - rlc_sn_t sn_prev = rlc_pP->vr_r; - rlc_sn_t sn_end = rlc_pP->vr_ms; - bool segment_loop_end = false; - - if (sn_prev != sn_end) { - while ((RLC_AM_DIFF_SN(sn_prev,rlc_pP->vr_r) < RLC_AM_DIFF_SN(sn_end,rlc_pP->vr_r)) && (cursor_p != NULL)) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t *)(cursor_p->data))->pdu_info; - sn_cursor = pdu_info_cursor_p->sn; - - // Add holes between sn_prev and sn_cursor - while ((sn_prev != sn_cursor) && (sn_prev != sn_end)) { - /* Add 1 NACK_SN + E1 + E2 */ - nb_bits_to_transmit += (RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1)); - sn_prev = RLC_AM_NEXT_SN(sn_prev); - } //end while (sn_prev != sn_cursor) - - /* Handle case sn_cursor is partially received */ - /* Each gap will add NACK_SN + E1 + E2 + SOStart + SOEnd */ - if ((((rlc_am_rx_pdu_management_t *)(cursor_p->data))->all_segments_received == 0) && (RLC_AM_DIFF_SN(sn_cursor,rlc_pP->vr_r) < RLC_AM_DIFF_SN(sn_end,rlc_pP->vr_r))) { - /* Check lsf */ - segment_loop_end = (pdu_info_cursor_p->lsf == 1); - - /* Fill for [0 SO[ if SO not null */ - if (pdu_info_cursor_p->so) { - nb_bits_to_transmit += (RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) + (RLC_AM_STATUS_PDU_SO_LENGTH << 1)); - waited_so = pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size; - } else { - waited_so = pdu_info_cursor_p->payload_size; - } - - /* Go to next segment */ - cursor_p = cursor_p->next; - - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t *)(cursor_p->data))->pdu_info; - } - - /* Fill following gaps if any */ - while (!segment_loop_end) { - if ((cursor_p != NULL) && (pdu_info_cursor_p->sn == sn_cursor)) { - /* Check lsf */ - segment_loop_end = (pdu_info_cursor_p->lsf == 1); - - if (waited_so < pdu_info_cursor_p->so) { - nb_bits_to_transmit += (RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) + (RLC_AM_STATUS_PDU_SO_LENGTH << 1)); - } else { - /* contiguous segment: only update waited_so */ - /* Assuming so and payload_size updated according to duplication removal done at reception ... */ - waited_so += pdu_info_cursor_p->payload_size; - } - - /* Go to next received PDU or PDU Segment */ - cursor_p = cursor_p->next; - - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t *)(cursor_p->data))->pdu_info; - } - } else { - /* Fill last gap assuming LSF is not received */ - nb_bits_to_transmit += (RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) + (RLC_AM_STATUS_PDU_SO_LENGTH << 1)); - segment_loop_end = true; - } - } // end while (!segment_loop_end) - } // end if segments - else { - /* 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); - } - } // end if (sn_prev != sn_end) - - // round up to the greatest byte - return ((nb_bits_to_transmit + 7) >> 3); -} - -//----------------------------------------------------------------------------- -uint32_t -rlc_am_get_buffer_occupancy_in_bytes ( - const protocol_ctxt_t *const ctxt_pP, - rlc_am_entity_t *const rlc_pP) { - // priority of control trafic - rlc_pP->status_buffer_occupancy = 0; - - if ((rlc_pP->status_requested) && !(rlc_pP->status_requested & RLC_AM_STATUS_NO_TX_MASK)) { - rlc_pP->status_buffer_occupancy = rlc_am_get_status_pdu_buffer_occupancy(rlc_pP); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" BO : CONTROL PDU %d bytes \n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->status_buffer_occupancy); - } - - if ( LOG_DEBUGFLAG(DEBUG_RLC)) { - if ((rlc_pP->status_buffer_occupancy + rlc_pP->retrans_num_bytes_to_retransmit + rlc_pP->sdu_buffer_occupancy ) > 0) { - LOG_UI(RLC, PROTOCOL_RLC_AM_CTXT_FMT" BO : STATUS BUFFER %d bytes \n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->status_buffer_occupancy); - LOG_UI(RLC, PROTOCOL_RLC_AM_CTXT_FMT" BO : RETRANS BUFFER %d bytes \n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->retrans_num_bytes_to_retransmit); - LOG_UI(RLC, PROTOCOL_RLC_AM_CTXT_FMT" BO : SDU BUFFER %d bytes + li_overhead %d bytes header_overhead %d bytes (nb sdu not segmented %d)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->sdu_buffer_occupancy, - 0, - 0, - rlc_pP->nb_sdu_no_segmented); - } - } - - return rlc_pP->status_buffer_occupancy + rlc_pP->retrans_num_bytes_to_retransmit + rlc_pP->sdu_buffer_occupancy; -} -//----------------------------------------------------------------------------- -void -rlc_am_release ( - const protocol_ctxt_t *const ctxt_pP, - rlc_am_entity_t *const rlc_pP -) { - // empty -} -//----------------------------------------------------------------------------- -void -config_req_rlc_am ( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const rlc_am_info_t *config_am_pP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP -) { - rlc_union_t *rlc_union_p = NULL; - rlc_am_entity_t *l_rlc_p = NULL; - hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); - hashtable_rc_t h_rc; - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - if (h_rc == HASH_TABLE_OK) { - l_rlc_p = &rlc_union_p->rlc.am; - LOG_D(RLC, - PROTOCOL_RLC_AM_CTXT_FMT" CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), - config_am_pP->max_retx_threshold, - config_am_pP->poll_pdu, - config_am_pP->poll_byte, - config_am_pP->t_poll_retransmit, - config_am_pP->t_reordering, - config_am_pP->t_status_prohibit); - rlc_am_init(ctxt_pP, l_rlc_p); - rlc_am_set_debug_infos(ctxt_pP, l_rlc_p, srb_flagP, rb_idP, chan_idP); - rlc_am_configure(ctxt_pP, l_rlc_p, - config_am_pP->max_retx_threshold, - config_am_pP->poll_pdu, - config_am_pP->poll_byte, - config_am_pP->t_poll_retransmit, - config_am_pP->t_reordering, - config_am_pP->t_status_prohibit); - } else { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" CONFIG_REQ RLC NOT FOUND\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p)); - } -} -uint16_t pollPDU_tab[LTE_PollPDU_pInfinity+1]= {4,8,16,32,64,128,256,RLC_AM_POLL_PDU_INFINITE}; //PollPDU_pInfinity is chosen to 0xFFFF for now -uint32_t maxRetxThreshold_tab[LTE_UL_AM_RLC__maxRetxThreshold_t32+1]= {1,2,3,4,6,8,16,32}; -uint32_t pollByte_tab[LTE_PollByte_spare1]= {25000,50000,75000,100000,125000,250000,375000,500000,750000,1000000,1250000,1500000,2000000,3000000,RLC_AM_POLL_BYTE_INFINITE}; // PollByte_kBinfinity is chosen to 0xFFFFFFFF for now -uint32_t PollRetransmit_tab[LTE_T_PollRetransmit_spare5]= {5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,300,350,400,450,500,800,1000,2000,4000}; -uint32_t am_t_Reordering_tab[32]= {0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,110,120,130,140,150,160,170,180,190,200,1600}; -uint32_t t_StatusProhibit_tab[LTE_T_StatusProhibit_spare2]= {0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,300,350,400,450,500,800,1000,1200,1600,2000,2400}; - - -//----------------------------------------------------------------------------- -void config_req_rlc_am_asn1 ( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const struct LTE_RLC_Config__am *const config_am_pP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP) { - rlc_union_t *rlc_union_p = NULL; - rlc_am_entity_t *l_rlc_p = NULL; - hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); - hashtable_rc_t h_rc; - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - if (h_rc == HASH_TABLE_OK) { - l_rlc_p = &rlc_union_p->rlc.am; - - if ((config_am_pP->ul_AM_RLC.maxRetxThreshold <= LTE_UL_AM_RLC__maxRetxThreshold_t32) && - (config_am_pP->ul_AM_RLC.pollPDU<=LTE_PollPDU_pInfinity) && - (config_am_pP->ul_AM_RLC.pollByte<LTE_PollByte_spare1) && - (config_am_pP->ul_AM_RLC.t_PollRetransmit<LTE_T_PollRetransmit_spare5) && - (config_am_pP->dl_AM_RLC.t_Reordering<32) && - (config_am_pP->dl_AM_RLC.t_StatusProhibit<LTE_T_StatusProhibit_spare2) ) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), - maxRetxThreshold_tab[config_am_pP->ul_AM_RLC.maxRetxThreshold], - pollPDU_tab[config_am_pP->ul_AM_RLC.pollPDU], - pollByte_tab[config_am_pP->ul_AM_RLC.pollByte], - PollRetransmit_tab[config_am_pP->ul_AM_RLC.t_PollRetransmit], - am_t_Reordering_tab[config_am_pP->dl_AM_RLC.t_Reordering], - t_StatusProhibit_tab[config_am_pP->dl_AM_RLC.t_StatusProhibit]); - rlc_am_init(ctxt_pP, l_rlc_p); - rlc_am_set_debug_infos(ctxt_pP, l_rlc_p, srb_flagP, rb_idP, chan_idP); - rlc_am_configure(ctxt_pP, l_rlc_p, - maxRetxThreshold_tab[config_am_pP->ul_AM_RLC.maxRetxThreshold], - pollPDU_tab[config_am_pP->ul_AM_RLC.pollPDU], - pollByte_tab[config_am_pP->ul_AM_RLC.pollByte], - PollRetransmit_tab[config_am_pP->ul_AM_RLC.t_PollRetransmit], - am_t_Reordering_tab[config_am_pP->dl_AM_RLC.t_Reordering], - t_StatusProhibit_tab[config_am_pP->dl_AM_RLC.t_StatusProhibit]); - } else { - LOG_D(RLC, - PROTOCOL_RLC_AM_CTXT_FMT"ILLEGAL CONFIG_REQ (max_retx_threshold=%ld poll_pdu=%ld poll_byte=%ld t_poll_retransmit=%ld t_reord=%ld t_status_prohibit=%ld), RLC-AM NOT CONFIGURED\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), - config_am_pP->ul_AM_RLC.maxRetxThreshold, - config_am_pP->ul_AM_RLC.pollPDU, - config_am_pP->ul_AM_RLC.pollByte, - config_am_pP->ul_AM_RLC.t_PollRetransmit, - config_am_pP->dl_AM_RLC.t_Reordering, - config_am_pP->dl_AM_RLC.t_StatusProhibit); - } - } else { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"CONFIG_REQ RLC NOT FOUND\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p)); - } -} - -//----------------------------------------------------------------------------- -void rlc_am_stat_req ( - const protocol_ctxt_t *const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - unsigned int *stat_tx_pdcp_sdu, - unsigned int *stat_tx_pdcp_bytes, - unsigned int *stat_tx_pdcp_sdu_discarded, - unsigned int *stat_tx_pdcp_bytes_discarded, - unsigned int *stat_tx_data_pdu, - unsigned int *stat_tx_data_bytes, - unsigned int *stat_tx_retransmit_pdu_by_status, - unsigned int *stat_tx_retransmit_bytes_by_status, - unsigned int *stat_tx_retransmit_pdu, - unsigned int *stat_tx_retransmit_bytes, - unsigned int *stat_tx_control_pdu, - unsigned int *stat_tx_control_bytes, - unsigned int *stat_rx_pdcp_sdu, - unsigned int *stat_rx_pdcp_bytes, - unsigned int *stat_rx_data_pdus_duplicate, - unsigned int *stat_rx_data_bytes_duplicate, - unsigned int *stat_rx_data_pdu, - unsigned int *stat_rx_data_bytes, - unsigned int *stat_rx_data_pdu_dropped, - unsigned int *stat_rx_data_bytes_dropped, - unsigned int *stat_rx_data_pdu_out_of_window, - unsigned int *stat_rx_data_bytes_out_of_window, - unsigned int *stat_rx_control_pdu, - unsigned int *stat_rx_control_bytes, - unsigned int *stat_timer_reordering_timed_out, - unsigned int *stat_timer_poll_retransmit_timed_out, - unsigned int *stat_timer_status_prohibit_timed_out) { - *stat_tx_pdcp_sdu = rlc_pP->stat_tx_pdcp_sdu; - *stat_tx_pdcp_bytes = rlc_pP->stat_tx_pdcp_bytes; - *stat_tx_pdcp_sdu_discarded = rlc_pP->stat_tx_pdcp_sdu_discarded; - *stat_tx_pdcp_bytes_discarded = rlc_pP->stat_tx_pdcp_bytes_discarded; - *stat_tx_data_pdu = rlc_pP->stat_tx_data_pdu; - *stat_tx_data_bytes = rlc_pP->stat_tx_data_bytes; - *stat_tx_retransmit_pdu_by_status = rlc_pP->stat_tx_retransmit_pdu_by_status; - *stat_tx_retransmit_bytes_by_status = rlc_pP->stat_tx_retransmit_bytes_by_status; - *stat_tx_retransmit_pdu = rlc_pP->stat_tx_retransmit_pdu; - *stat_tx_retransmit_bytes = rlc_pP->stat_tx_retransmit_bytes; - *stat_tx_control_pdu = rlc_pP->stat_tx_control_pdu; - *stat_tx_control_bytes = rlc_pP->stat_tx_control_bytes; - *stat_rx_pdcp_sdu = rlc_pP->stat_rx_pdcp_sdu; - *stat_rx_pdcp_bytes = rlc_pP->stat_rx_pdcp_bytes; - *stat_rx_data_pdus_duplicate = rlc_pP->stat_rx_data_pdus_duplicate; - *stat_rx_data_bytes_duplicate = rlc_pP->stat_rx_data_bytes_duplicate; - *stat_rx_data_pdu = rlc_pP->stat_rx_data_pdu; - *stat_rx_data_bytes = rlc_pP->stat_rx_data_bytes; - *stat_rx_data_pdu_dropped = rlc_pP->stat_rx_data_pdu_dropped; - *stat_rx_data_bytes_dropped = rlc_pP->stat_rx_data_bytes_dropped; - *stat_rx_data_pdu_out_of_window = rlc_pP->stat_rx_data_pdu_out_of_window; - *stat_rx_data_bytes_out_of_window = rlc_pP->stat_rx_data_bytes_out_of_window; - *stat_rx_control_pdu = rlc_pP->stat_rx_control_pdu; - *stat_rx_control_bytes = rlc_pP->stat_rx_control_bytes; - *stat_timer_reordering_timed_out = rlc_pP->stat_timer_reordering_timed_out; - *stat_timer_poll_retransmit_timed_out = rlc_pP->stat_timer_poll_retransmit_timed_out; - *stat_timer_status_prohibit_timed_out = rlc_pP->stat_timer_status_prohibit_timed_out; -} -//----------------------------------------------------------------------------- -void -rlc_am_get_pdus ( - const protocol_ctxt_t *const ctxt_pP, - rlc_am_entity_t *const rlc_pP -) { - //int display_flag = 0; - // 5.1.3.1 Transmit operations - // 5.1.3.1.1 - // General - // The transmitting side of an AM RLC entity shall prioritize transmission of RLC control PDUs over RLC data PDUs. - // The transmitting side of an AM RLC entity shall prioritize retransmission of RLC data PDUs over transmission of new - // AMD PDUs. - switch (rlc_pP->protocol_state) { - case RLC_NULL_STATE: - break; - - case RLC_DATA_TRANSFER_READY_STATE: - - // TRY TO SEND CONTROL PDU FIRST - if ((rlc_pP->nb_bytes_requested_by_mac >= 2) && - ((rlc_pP->status_requested) && !(rlc_pP->status_requested & RLC_AM_STATUS_NO_TX_MASK))) { - // When STATUS reporting has been triggered, the receiving side of an AM RLC entity shall: - // - if t-StatusProhibit is not running: - // - at the first transmission opportunity indicated by lower layer, construct a STATUS PDU and deliver it to lower layer; - // - else: - // - at the first transmission opportunity indicated by lower layer after t-StatusProhibit expires, construct a single - // STATUS PDU even if status reporting was triggered several times while t-StatusProhibit was running and - // deliver it to lower layer; - // - // When a STATUS PDU has been delivered to lower layer, the receiving side of an AM RLC entity shall: - // - start t-StatusProhibit. - rlc_am_send_status_pdu(ctxt_pP, rlc_pP); - mem_block_t *pdu = list_remove_head(&rlc_pP->control_pdu_list); - - if (pdu) { - list_add_tail_eurecom (pdu, &rlc_pP->pdus_to_mac_layer); - RLC_AM_CLEAR_ALL_STATUS(rlc_pP->status_requested); - rlc_pP->status_buffer_occupancy = 0; - rlc_am_start_timer_status_prohibit(ctxt_pP, rlc_pP); - return; - } - } else { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" DELAYED SENT STATUS PDU (Available MAC Data %u)(T-PROHIBIT %u) (DELAY FLAG %u)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->nb_bytes_requested_by_mac,rlc_pP->t_status_prohibit.ms_time_out,(rlc_pP->status_requested & RLC_AM_STATUS_TRIGGERED_DELAYED)); - } - - // THEN TRY TO SEND RETRANS PDU - if ((rlc_pP->retrans_num_bytes_to_retransmit) && (rlc_pP->nb_bytes_requested_by_mac > 2)) { - /* Get 1 AM data PDU or PDU segment to retransmit */ - mem_block_t *pdu_retx = rlc_am_get_pdu_to_retransmit(ctxt_pP, rlc_pP); - - if (pdu_retx != NULL) { - list_add_tail_eurecom (pdu_retx, &rlc_pP->pdus_to_mac_layer); - return; - } - } - - // THEN TRY TO SEND NEW DATA PDU - if ((rlc_pP->nb_bytes_requested_by_mac > 2) && (rlc_pP->sdu_buffer_occupancy) && (rlc_pP->vt_s != rlc_pP->vt_ms)) { - rlc_am_segment_10(ctxt_pP, rlc_pP); - list_add_list (&rlc_pP->segmentation_pdu_list, &rlc_pP->pdus_to_mac_layer); - - if (rlc_pP->pdus_to_mac_layer.head != NULL) { - rlc_pP->stat_tx_data_pdu += 1; - rlc_pP->stat_tx_data_bytes += (((struct mac_tb_req *)(rlc_pP->pdus_to_mac_layer.head->data))->tb_size); - return; - } - } - - break; - - default: - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" MAC_DATA_REQ UNKNOWN PROTOCOL STATE 0x%02X\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->protocol_state); - } -} -//----------------------------------------------------------------------------- -void -rlc_am_rx ( - const protocol_ctxt_t *const ctxt_pP, - void *const arg_pP, - struct mac_data_ind data_indP -) { - rlc_am_entity_t *rlc = (rlc_am_entity_t *) arg_pP; - - switch (rlc->protocol_state) { - case RLC_NULL_STATE: - LOG_I(RLC, PROTOCOL_RLC_AM_CTXT_FMT" ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP, rlc)); - list_free (&data_indP.data); - break; - - case RLC_DATA_TRANSFER_READY_STATE: - rlc_am_receive_routing (ctxt_pP, rlc, data_indP); - break; - - default: - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" TX UNKNOWN PROTOCOL STATE 0x%02X\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP, rlc), rlc->protocol_state); - list_free (&data_indP.data); - } -} - -//----------------------------------------------------------------------------- -struct mac_status_resp -rlc_am_mac_status_indication ( - const protocol_ctxt_t *const ctxt_pP, - void *const rlc_pP, - struct mac_status_ind tx_statusP, - const eNB_flag_t enb_flagP) { - struct mac_status_resp status_resp; - uint16_t sdu_size = 0; - uint16_t sdu_remaining_size = 0; - int32_t diff_time=0; - rlc_am_entity_t *rlc = (rlc_am_entity_t *) rlc_pP; - status_resp.buffer_occupancy_in_bytes = 0; - status_resp.buffer_occupancy_in_pdus = 0; - status_resp.head_sdu_remaining_size_to_send = 0; - status_resp.head_sdu_creation_time = 0; - status_resp.head_sdu_is_segmented = 0; - status_resp.rlc_info.rlc_protocol_state = rlc->protocol_state; - - /* TODO: remove this hack. Problem is: there is a race. - * UE comes. SRB2 is configured via message to RRC. - * At some point the RLC AM is created but not configured yet. - * At this moment (I think) MAC calls mac_rlc_status_ind - * which calls this function. But the init was not finished yet - * and we have a crash below when testing mem_block != NULL. - */ - if (rlc->input_sdus == NULL) return status_resp; - - if (rlc->last_absolute_subframe_status_indication != (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP))) { - rlc_am_check_timer_poll_retransmit(ctxt_pP, rlc); - rlc_am_check_timer_reordering(ctxt_pP, rlc); - rlc_am_check_timer_status_prohibit(ctxt_pP, rlc); - } - - rlc->last_absolute_subframe_status_indication = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); - - status_resp.buffer_occupancy_in_bytes = rlc_am_get_buffer_occupancy_in_bytes(ctxt_pP, rlc); - - // For eNB scheduler : Add Max RLC header size for new PDU - // For UE : do not add RLC header part to be compliant with BSR definition in 36.321 - if (enb_flagP == ENB_FLAG_YES) { - uint32_t max_li_overhead = 0; - uint32_t header_overhead = 0; - - if (rlc->nb_sdu_no_segmented > 1) { - /* This computation assumes there is no SDU with size greater than 2047 bytes, otherwise a new PDU must be built except for LI15 configuration from Rel12*/ - uint32_t num_li = rlc->nb_sdu_no_segmented - 1; - max_li_overhead = num_li + (num_li >> 1) + (num_li & 1); - } - - if (rlc->sdu_buffer_occupancy > 0) { - header_overhead = 2; - } - - status_resp.buffer_occupancy_in_bytes += (header_overhead + max_li_overhead); - } - - if ((rlc->input_sdus[rlc->current_sdu_index].mem_block != NULL) && (status_resp.buffer_occupancy_in_bytes)) { - //status_resp.buffer_occupancy_in_bytes += ((rlc_am_entity_t *) rlc)->tx_header_min_length_in_bytes; - status_resp.buffer_occupancy_in_pdus = rlc->nb_sdu; - diff_time = ctxt_pP->frame - ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_creation_time; - status_resp.head_sdu_creation_time = (diff_time > 0 ) ? (uint32_t) diff_time : (uint32_t)(0xffffffff - diff_time + ctxt_pP->frame) ; - sdu_size = ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_size; - sdu_remaining_size = ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->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_is_segmented = 0; - } else { - status_resp.head_sdu_is_segmented = 1; - } - } else { - /* Not so many possibilities ... */ - /* either buffer_occupancy_in_bytes = 0 and that's it */ - /* or we have segmented all received SDUs and buffer occupancy is then made of retransmissions and/or status pdu pending */ - /* then consider only retransmission buffer for the specific BO values used by eNB scheduler (not used up to now...) */ - if (rlc->retrans_num_bytes_to_retransmit) { - status_resp.buffer_occupancy_in_pdus = rlc->retrans_num_pdus; - status_resp.head_sdu_remaining_size_to_send = rlc->retrans_num_bytes_to_retransmit; - status_resp.head_sdu_is_segmented = 1; - } - } - - if (LOG_DEBUGFLAG(DEBUG_RLC)) { - LOG_UI(RLC, PROTOCOL_RLC_AM_CTXT_FMT" MAC_STATUS_INDICATION (DATA) -> %d bytes\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc), - status_resp.buffer_occupancy_in_bytes); - } - - return status_resp; -} - -//----------------------------------------------------------------------------- -struct mac_data_req -rlc_am_mac_data_request ( - const protocol_ctxt_t *const ctxt_pP, - void *const rlc_pP, - const eNB_flag_t enb_flagP -) { - struct mac_data_req data_req; - rlc_am_entity_t *l_rlc_p = (rlc_am_entity_t *) rlc_pP; - unsigned int nb_bytes_requested_by_mac = ((rlc_am_entity_t *) rlc_pP)->nb_bytes_requested_by_mac; - rlc_am_pdu_info_t pdu_info; - rlc_am_pdu_sn_10_t *rlc_am_pdu_sn_10_p; - mem_block_t *tb_p; - tb_size_t tb_size_in_bytes; - int num_nack; - char message_string[9000]; - size_t message_string_size = 0; - int octet_index, index; - /* for no gcc warnings */ - (void)num_nack; - (void)message_string; - (void)message_string_size; - (void)octet_index; - (void)index; - list_init (&data_req.data, NULL); - rlc_am_get_pdus (ctxt_pP, l_rlc_p); - list_add_list (&l_rlc_p->pdus_to_mac_layer, &data_req.data); - - //((rlc_am_entity_t *) rlc_pP)->tx_pdus += data_req.data.nb_elements; - if ((nb_bytes_requested_by_mac + data_req.data.nb_elements) > 0) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" MAC_DATA_REQUEST %05d BYTES REQUESTED -> %d TBs\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), - nb_bytes_requested_by_mac, - data_req.data.nb_elements); - } - - if (enb_flagP) { - // redundant in UE MAC Tx processing and not used in eNB ... - data_req.buffer_occupancy_in_bytes = rlc_am_get_buffer_occupancy_in_bytes(ctxt_pP, l_rlc_p); - } - - data_req.rlc_info.rlc_protocol_state = l_rlc_p->protocol_state; - - if ( (LOG_DEBUGFLAG(DEBUG_RLC))&& data_req.data.nb_elements > 0) { - tb_p = data_req.data.head; - - while (tb_p != NULL) { - rlc_am_pdu_sn_10_p = (rlc_am_pdu_sn_10_t *)((struct mac_tb_req *) (tb_p->data))->data_ptr; - tb_size_in_bytes = ((struct mac_tb_req *) (tb_p->data))->tb_size; - - if ((((struct mac_tb_req *) (tb_p->data))->data_ptr[0] & RLC_DC_MASK) == RLC_DC_DATA_PDU ) { - if (rlc_am_get_data_pdu_infos(ctxt_pP,l_rlc_p,rlc_am_pdu_sn_10_p, tb_size_in_bytes, &pdu_info) >= 0) { - if ( LOG_DEBUGFLAG(DEBUG_RLC)) { - message_string_size = 0; - message_string_size += sprintf(&message_string[message_string_size], "Bearer : %ld\n", l_rlc_p->rb_id); - message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", tb_size_in_bytes); - message_string_size += sprintf(&message_string[message_string_size], "Header size : %u\n", pdu_info.header_size); - message_string_size += sprintf(&message_string[message_string_size], "Payload size: %u\n", pdu_info.payload_size); - - if (pdu_info.rf) { - message_string_size += sprintf(&message_string[message_string_size], "PDU type : RLC AM DATA REQ: AMD PDU segment\n\n"); - } else { - message_string_size += sprintf(&message_string[message_string_size], "PDU type : RLC AM DATA REQ: AMD PDU\n\n"); - } - - message_string_size += sprintf(&message_string[message_string_size], "Header :\n"); - message_string_size += sprintf(&message_string[message_string_size], " D/C : %u\n", pdu_info.d_c); - message_string_size += sprintf(&message_string[message_string_size], " RF : %u\n", pdu_info.rf); - message_string_size += sprintf(&message_string[message_string_size], " P : %u\n", pdu_info.p); - message_string_size += sprintf(&message_string[message_string_size], " FI : %u\n", pdu_info.fi); - message_string_size += sprintf(&message_string[message_string_size], " E : %u\n", pdu_info.e); - message_string_size += sprintf(&message_string[message_string_size], " SN : %u\n", pdu_info.sn); - - if (pdu_info.rf) { - message_string_size += sprintf(&message_string[message_string_size], " LSF : %u\n", pdu_info.lsf); - message_string_size += sprintf(&message_string[message_string_size], " SO : %u\n", pdu_info.so); - } - - if (pdu_info.e) { - message_string_size += sprintf(&message_string[message_string_size], "\nHeader extension : \n"); - - for (index=0; index < pdu_info.num_li; index++) { - message_string_size += sprintf(&message_string[message_string_size], " LI : %u\n", pdu_info.li_list[index]); - } - } - - message_string_size += sprintf(&message_string[message_string_size], "\nPayload : \n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - message_string_size += sprintf(&message_string[message_string_size], " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - - for (octet_index = 0; octet_index < pdu_info.payload_size; octet_index++) { - if ((octet_index % 16) == 0) { - if (octet_index != 0) { - message_string_size += sprintf(&message_string[message_string_size], " |\n"); - } - - message_string_size += sprintf(&message_string[message_string_size], " %04d |", octet_index); - } - - /* - * Print every single octet in hexadecimal form - */ - message_string_size += sprintf(&message_string[message_string_size], " %02x", pdu_info.payload[octet_index]); - /* - * Align newline and pipes according to the octets in groups of 2 - */ - } - - /* - * Append enough spaces and put final pipe - */ - for (index = octet_index; index < 16; ++index) { - message_string_size += sprintf(&message_string[message_string_size], " "); - } - - LOG_UI(RLC,"%s\n",message_string); - } /* LOG_DEBUGFLAG(DEBUG_RLC) */ - } - } else { - if (rlc_am_get_control_pdu_infos(rlc_am_pdu_sn_10_p, &tb_size_in_bytes, &l_rlc_p->control_pdu_info) >= 0) { - tb_size_in_bytes = ((struct mac_tb_req *) (tb_p->data))->tb_size; //tb_size_in_bytes modified by rlc_am_get_control_pdu_infos! - - if ( LOG_DEBUGFLAG(DEBUG_RLC)) { - message_string_size = 0; - message_string_size += sprintf(&message_string[message_string_size], "Bearer : %ld\n", l_rlc_p->rb_id); - message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", tb_size_in_bytes); - message_string_size += sprintf(&message_string[message_string_size], "PDU type : RLC AM DATA REQ: STATUS PDU\n\n"); - message_string_size += sprintf(&message_string[message_string_size], "Header :\n"); - message_string_size += sprintf(&message_string[message_string_size], " D/C : %u\n", l_rlc_p->control_pdu_info.d_c); - message_string_size += sprintf(&message_string[message_string_size], " CPT : %u\n", l_rlc_p->control_pdu_info.cpt); - message_string_size += sprintf(&message_string[message_string_size], " ACK_SN : %u\n", l_rlc_p->control_pdu_info.ack_sn); - message_string_size += sprintf(&message_string[message_string_size], " E1 : %u\n", l_rlc_p->control_pdu_info.e1); - - for (num_nack = 0; num_nack < l_rlc_p->control_pdu_info.num_nack; num_nack++) { - if (l_rlc_p->control_pdu_info.nack_list[num_nack].e2) { - message_string_size += sprintf(&message_string[message_string_size], " NACK SN %04d SO START %05d SO END %05d", - l_rlc_p->control_pdu_info.nack_list[num_nack].nack_sn, - l_rlc_p->control_pdu_info.nack_list[num_nack].so_start, - l_rlc_p->control_pdu_info.nack_list[num_nack].so_end); - } else { - message_string_size += sprintf(&message_string[message_string_size], " NACK SN %04d", l_rlc_p->control_pdu_info.nack_list[num_nack].nack_sn); - } - } - - LOG_UI(RLC,"%s\n",message_string); - } /* LOG_DEBUGFLAG(DEBUG_RLC) */ - } - } - - tb_p = tb_p->next; - } /* while */ - } /* data_req.data.nb_elements > 0 */ - - data_req.buffer_occupancy_in_pdus = 0; - return data_req; -} -//----------------------------------------------------------------------------- -void -rlc_am_mac_data_indication ( - const protocol_ctxt_t *const ctxt_pP, - void *const rlc_pP, - struct mac_data_ind data_indP -) { - rlc_am_entity_t *l_rlc_p = (rlc_am_entity_t *) rlc_pP; - /*rlc_am_control_pdu_info_t control_pdu_info; - int num_li; - int16_t tb_size;*/ - rlc_am_pdu_info_t pdu_info; - rlc_am_pdu_sn_10_t *rlc_am_pdu_sn_10_p; - mem_block_t *tb_p; - sdu_size_t tb_size_in_bytes; - int num_nack; - char message_string[7000]; - size_t message_string_size = 0; - int octet_index, index; - /* for no gcc warnings */ - (void)num_nack; - (void)message_string; - (void)message_string_size; - (void)octet_index; - (void)index; - (void)l_rlc_p; /* avoid gcc warning "unused variable" */ - - if ( LOG_DEBUGFLAG(DEBUG_RLC)) { - if (data_indP.data.nb_elements > 0) { - tb_p = data_indP.data.head; - - while (tb_p != NULL) { - rlc_am_pdu_sn_10_p = (rlc_am_pdu_sn_10_t *)((struct mac_tb_ind *) (tb_p->data))->data_ptr; - tb_size_in_bytes = ((struct mac_tb_ind *) (tb_p->data))->size; - - if ((((struct mac_tb_ind *) (tb_p->data))->data_ptr[0] & RLC_DC_MASK) == RLC_DC_DATA_PDU ) { - if (rlc_am_get_data_pdu_infos(ctxt_pP,l_rlc_p,rlc_am_pdu_sn_10_p, tb_size_in_bytes, &pdu_info) >= 0) { - if ( LOG_DEBUGFLAG(DEBUG_RLC)) { - message_string_size += sprintf(&message_string[message_string_size], "Bearer : %ld\n", l_rlc_p->rb_id); - message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", tb_size_in_bytes); - message_string_size += sprintf(&message_string[message_string_size], "Header size : %u\n", pdu_info.header_size); - message_string_size += sprintf(&message_string[message_string_size], "Payload size: %u\n", pdu_info.payload_size); - - if (pdu_info.rf) { - message_string_size += sprintf(&message_string[message_string_size], "PDU type : RLC AM DATA IND: AMD PDU segment\n\n"); - } else { - message_string_size += sprintf(&message_string[message_string_size], "PDU type : RLC AM DATA IND: AMD PDU\n\n"); - } - - message_string_size += sprintf(&message_string[message_string_size], "Header :\n"); - message_string_size += sprintf(&message_string[message_string_size], " D/C : %u\n", pdu_info.d_c); - message_string_size += sprintf(&message_string[message_string_size], " RF : %u\n", pdu_info.rf); - message_string_size += sprintf(&message_string[message_string_size], " P : %u\n", pdu_info.p); - message_string_size += sprintf(&message_string[message_string_size], " FI : %u\n", pdu_info.fi); - message_string_size += sprintf(&message_string[message_string_size], " E : %u\n", pdu_info.e); - message_string_size += sprintf(&message_string[message_string_size], " SN : %u\n", pdu_info.sn); - - if (pdu_info.rf) { - message_string_size += sprintf(&message_string[message_string_size], " LSF : %u\n", pdu_info.lsf); - message_string_size += sprintf(&message_string[message_string_size], " SO : %u\n", pdu_info.so); - } - - if (pdu_info.e) { - message_string_size += sprintf(&message_string[message_string_size], "\nHeader extension : \n"); - - for (index=0; index < pdu_info.num_li; index++) { - message_string_size += sprintf(&message_string[message_string_size], " LI : %u\n", pdu_info.li_list[index]); - } - } - - message_string_size += sprintf(&message_string[message_string_size], "\nPayload : \n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - message_string_size += sprintf(&message_string[message_string_size], " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - - for (octet_index = 0; octet_index < pdu_info.payload_size; octet_index++) { - if ((octet_index % 16) == 0) { - if (octet_index != 0) { - message_string_size += sprintf(&message_string[message_string_size], " |\n"); - } - - message_string_size += sprintf(&message_string[message_string_size], " %04d |", octet_index); - } - - /* - * Print every single octet in hexadecimal form - */ - message_string_size += sprintf(&message_string[message_string_size], " %02x", pdu_info.payload[octet_index]); - /* - * Align newline and pipes according to the octets in groups of 2 - */ - } - - /* - * Append enough spaces and put final pipe - */ - for (index = octet_index; index < 16; ++index) { - message_string_size += sprintf(&message_string[message_string_size], " "); - } - - LOG_UI(RLC,"%s\n",message_string); - } /* LOG_DEBUGFLAG */ - } - } else { - if (rlc_am_get_control_pdu_infos(rlc_am_pdu_sn_10_p, &tb_size_in_bytes, &l_rlc_p->control_pdu_info) >= 0) { - if ( LOG_DEBUGFLAG(DEBUG_RLC)) { - message_string_size = 0; - message_string_size += sprintf(&message_string[message_string_size], "Bearer : %ld\n", l_rlc_p->rb_id); - message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", ((struct mac_tb_ind *) (tb_p->data))->size); - message_string_size += sprintf(&message_string[message_string_size], "PDU type : RLC AM DATA IND: STATUS PDU\n\n"); - message_string_size += sprintf(&message_string[message_string_size], "Header :\n"); - message_string_size += sprintf(&message_string[message_string_size], " D/C : %u\n", l_rlc_p->control_pdu_info.d_c); - message_string_size += sprintf(&message_string[message_string_size], " CPT : %u\n", l_rlc_p->control_pdu_info.cpt); - message_string_size += sprintf(&message_string[message_string_size], " ACK_SN : %u\n", l_rlc_p->control_pdu_info.ack_sn); - message_string_size += sprintf(&message_string[message_string_size], " E1 : %u\n", l_rlc_p->control_pdu_info.e1); - - for (num_nack = 0; num_nack < l_rlc_p->control_pdu_info.num_nack; num_nack++) { - if (l_rlc_p->control_pdu_info.nack_list[num_nack].e2) { - message_string_size += sprintf(&message_string[message_string_size], " NACK SN %04d SO START %05d SO END %05d", - l_rlc_p->control_pdu_info.nack_list[num_nack].nack_sn, - l_rlc_p->control_pdu_info.nack_list[num_nack].so_start, - l_rlc_p->control_pdu_info.nack_list[num_nack].so_end); - } else { - message_string_size += sprintf(&message_string[message_string_size], " NACK SN %04d", l_rlc_p->control_pdu_info.nack_list[num_nack].nack_sn); - } - } - - LOG_UI(RLC, "%s\n",message_string); - } - } - } - - tb_p = tb_p->next; - } - } - } /* LOG_DEBUGFLAG(RLC) || MESSAGE_TRACE_GENERATOR) */ - - rlc_am_rx (ctxt_pP, rlc_pP, data_indP); -} - -//----------------------------------------------------------------------------- -void -rlc_am_data_req ( - const protocol_ctxt_t *const ctxt_pP, - void *const rlc_pP, - mem_block_t *const sdu_pP) { - rlc_am_entity_t *l_rlc_p = (rlc_am_entity_t *) rlc_pP; - uint32_t mui; - uint16_t data_offset; - uint16_t data_size; - char message_string[7000]; - size_t message_string_size = 0; - int octet_index, index; - RLC_AM_MUTEX_LOCK(&l_rlc_p->lock_input_sdus, ctxt_pP, l_rlc_p); - - if ((l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].mem_block == NULL) && - (l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].flags.segmented == 0) && - (((l_rlc_p->next_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE) != l_rlc_p->current_sdu_index)) { - memset(&l_rlc_p->input_sdus[l_rlc_p->next_sdu_index], 0, sizeof(rlc_am_tx_sdu_management_t)); - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].mem_block = sdu_pP; - mui = ((struct rlc_am_data_req *) (sdu_pP->data))->mui; - data_offset = ((struct rlc_am_data_req *) (sdu_pP->data))->data_offset; - data_size = ((struct rlc_am_data_req *) (sdu_pP->data))->data_size; - - if (LOG_DEBUGFLAG(DEBUG_RLC)) { - message_string_size += sprintf(&message_string[message_string_size], "Bearer : %ld\n", l_rlc_p->rb_id); - message_string_size += sprintf(&message_string[message_string_size], "SDU size : %u\n", data_size); - message_string_size += sprintf(&message_string[message_string_size], "MUI : %u\n", mui); - message_string_size += sprintf(&message_string[message_string_size], "CONF : %u\n", ((struct rlc_am_data_req *) (sdu_pP->data))->conf); - message_string_size += sprintf(&message_string[message_string_size], "\nPayload : \n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - message_string_size += sprintf(&message_string[message_string_size], " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - - for (octet_index = 0; octet_index < data_size; octet_index++) { - if ((octet_index % 16) == 0) { - if (octet_index != 0) { - message_string_size += sprintf(&message_string[message_string_size], " |\n"); - } - - message_string_size += sprintf(&message_string[message_string_size], " %04d |", octet_index); - } - - /* - * Print every single octet in hexadecimal form - */ - message_string_size += sprintf(&message_string[message_string_size], " %02x", ((uint8_t *)(&sdu_pP->data[data_offset]))[octet_index]); - /* - * Align newline and pipes according to the octets in groups of 2 - */ - } - - /* - * Append enough spaces and put final pipe - */ - for (index = octet_index; index < 16; ++index) { - message_string_size += sprintf(&message_string[message_string_size], " "); - } - - message_string_size += sprintf(&message_string[message_string_size], " |\n"); - LOG_UI(RLC, "%s\n", message_string); - } /* LOG_DEBUGFLAG(RLC) */ - - l_rlc_p->stat_tx_pdcp_sdu += 1; - l_rlc_p->stat_tx_pdcp_bytes += data_size; - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].mui = mui; - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].sdu_size = data_size; - l_rlc_p->sdu_buffer_occupancy += data_size; - l_rlc_p->nb_sdu += 1; - l_rlc_p->nb_sdu_no_segmented += 1; - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].first_byte = (uint8_t *)(&sdu_pP->data[data_offset]); - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].sdu_remaining_size = l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].sdu_size; - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].sdu_segmented_size = 0; - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].sdu_creation_time = ctxt_pP->frame; - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].nb_pdus = 0; - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].nb_pdus_ack = 0; - //l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].nb_pdus_time = 0; - //l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].nb_pdus_internal_use = 0; - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].flags.discarded = 0; - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].flags.segmented = 0; - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].flags.segmentation_in_progress = 0; - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].flags.no_new_sdu_segmented_in_last_pdu = 0; - //l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].li_index_for_discard = -1; - l_rlc_p->next_sdu_index = (l_rlc_p->next_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; - - if (l_rlc_p->channel_id <3) { - LOG_I(RLC, PROTOCOL_RLC_AM_CTXT_FMT" RLC_AM_DATA_REQ size %d Bytes, NB SDU %d current_sdu_index=%d next_sdu_index=%d conf %d mui %d vtA %d vtS %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), - data_size, - l_rlc_p->nb_sdu, - l_rlc_p->current_sdu_index, - l_rlc_p->next_sdu_index, - ((struct rlc_am_data_req *) (sdu_pP->data))->conf, - mui, - l_rlc_p->vt_a, - l_rlc_p->vt_s); - } - } else { - LOG_W(RLC, PROTOCOL_RLC_AM_CTXT_FMT" RLC_AM_DATA_REQ BUFFER FULL, NB SDU %d current_sdu_index=%d next_sdu_index=%d size_input_sdus_buffer=%d vtA=%d vtS=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), - l_rlc_p->nb_sdu, - l_rlc_p->current_sdu_index, - l_rlc_p->next_sdu_index, - RLC_AM_SDU_CONTROL_BUFFER_SIZE, - l_rlc_p->vt_a, - l_rlc_p->vt_s); - LOG_W(RLC, " input_sdus[].mem_block=%p next input_sdus[].flags.segmented=%d\n", - l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].mem_block, l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].flags.segmented); - l_rlc_p->stat_tx_pdcp_sdu_discarded += 1; - l_rlc_p->stat_tx_pdcp_bytes_discarded += ((struct rlc_am_data_req *) (sdu_pP->data))->data_size; - free_mem_block (sdu_pP, __func__); -#if STOP_ON_IP_TRAFFIC_OVERLOAD - AssertFatal(0, PROTOCOL_RLC_AM_CTXT_FMT" RLC_AM_DATA_REQ size %d Bytes, SDU DROPPED, INPUT BUFFER OVERFLOW NB SDU %d current_sdu_index=%d next_sdu_index=%d \n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,l_rlc_p), - data_size, - l_rlc_p->nb_sdu, - l_rlc_p->current_sdu_index, - l_rlc_p->next_sdu_index); -#endif - } - - RLC_AM_MUTEX_UNLOCK(&l_rlc_p->lock_input_sdus); -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h deleted file mode 100644 index b4073303dde992dd941eabc744369bb4a6d4d50b..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am.h -* \brief This file, and only this file must be included by code that interact with RLC AM layer. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_impl_ RLC AM Layer Reference Implementation -* @ingroup _rlc_impl_ -* @{ -*/ - -# ifndef __RLC_AM_H__ -# define __RLC_AM_H__ -# include "platform_types.h" -# include "rlc_def.h" -# include "rlc_def_lte.h" -# include "rlc_am_constants.h" -# include "rlc_am_structs.h" -# include "rlc_am_entity.h" -# include "rlc_am_windows.h" -# include "mem_block.h" -# include "rlc_am_in_sdu.h" -# include "rlc_am_segment.h" -# include "rlc_am_segments_holes.h" -# include "rlc_am_timer_poll_retransmit.h" -# include "rlc_am_timer_reordering.h" -# include "rlc_am_timer_status_prohibit.h" -# include "rlc_am_retransmit.h" -# include "rlc_am_receiver.h" -# include "rlc_am_status_report.h" -# include "rlc_am_rx_list.h" -# include "rlc_am_reassembly.h" -# include "rlc_am_init.h" -# include "LTE_RLC-Config.h" -# include "assertions.h" -//# include "rlc_am_test.h" - - -#define PROTOCOL_RLC_AM_CTXT_FMT PROTOCOL_CTXT_FMT"[%s %02ld]" -#define PROTOCOL_RLC_AM_CTXT_ARGS(CTXT_Pp, rLC_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\ - (rLC_Pp->is_data_plane) ? "DRB AM" : "SRB AM",\ - rLC_Pp->rb_id - -#define PROTOCOL_RLC_AM_MSC_FMT "[RNTI %" PRIx16 " %s %02ld]" -#define PROTOCOL_RLC_AM_MSC_ARGS(CTXT_Pp, rLC_Pp) \ - CTXT_Pp->rnti,\ - (rLC_Pp->is_data_plane) ? "DRB AM" : "SRB AM",\ - rLC_Pp->rb_id - - -#if defined(TRACE_RLC_MUTEX) -#define RLC_AM_MUTEX_LOCK(mUTEX, cTXT, rLC) \ - do {\ - int pmtl_rc = pthread_mutex_trylock(mUTEX);\ - if (pmtl_rc != 0){\ - if (pmtl_rc == EBUSY) {\ - pthread_mutex_lock(mUTEX);\ - }\ - }\ - } while (0); -#else -#define RLC_AM_MUTEX_LOCK(mUTEX, cTXT, rLC) pthread_mutex_lock(mUTEX) -#endif - -#define RLC_AM_MUTEX_UNLOCK(mUTEX) pthread_mutex_unlock(mUTEX) - -/*! \fn void rlc_am_release (const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP) -* \brief Empty function, TO DO. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void rlc_am_release ( - const protocol_ctxt_t* const ctxtP, - rlc_am_entity_t * const rlc_pP); - -/** @addtogroup _rlc_am_init_impl_ -* @{ -*/ - -/*! \fn void config_req_rlc_am (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, rlc_am_info_t * config_amP, rb_id_t rb_idP, logical_chan_id_t chan_idP) -* \brief Configure the UL and DL parameters of the RLC AM -* \param[in] ctxt_pP Running context. -* \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). -* \param[in] config_amP Configuration parameters for RLC AM instance. -* \param[in] rb_idP Radio bearer identifier. -* \param[in] chan_idP Transport channel identifier. -*/ -void -config_req_rlc_am ( - const protocol_ctxt_t* const ctxt_pP, - const srb_flag_t srb_flagP, - const rlc_am_info_t * config_am_pP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP -); - -/*! \fn void config_req_rlc_am_asn1 (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, struct RLC_Config__am * config_amP, rb_id_t rb_idP, logical_chan_id_t chan_idP) -* \brief Configure the UL and DL parameters of the RLC AM with the asn1c autogenerated pameters structs -* \param[in] ctxt_pP Running context. -* \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). -* \param[in] config_amP Configuration parameters for RLC AM instance. -* \param[in] rb_idP Radio bearer identifier. -* \param[in] chan_idP Transport channel identifier. -*/ -void config_req_rlc_am_asn1 ( - const protocol_ctxt_t* const ctxtP, - const srb_flag_t srb_flagP, - const struct LTE_RLC_Config__am * const config_amP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP); - -/** @} */ - -/*! \fn void rlc_am_stat_req ( - const protocol_ctxt_t* const ctxtP, - rlc_am_entity_t * const rlc_pP, - unsigned int* stat_tx_pdcp_sdu, - unsigned int* stat_tx_pdcp_bytes, - unsigned int* stat_tx_pdcp_sdu_discarded, - unsigned int* stat_tx_pdcp_bytes_discarded, - unsigned int* stat_tx_data_pdu, - unsigned int* stat_tx_data_bytes, - unsigned int* stat_tx_retransmit_pdu_by_status, - unsigned int* stat_tx_retransmit_bytes_by_status, - unsigned int* stat_tx_retransmit_pdu, - unsigned int* stat_tx_retransmit_bytes, - unsigned int* stat_tx_control_pdu, - unsigned int* stat_tx_control_bytes, - unsigned int* stat_rx_pdcp_sdu, - unsigned int* stat_rx_pdcp_bytes, - unsigned int* stat_rx_data_pdus_duplicate, - unsigned int* stat_rx_data_bytes_duplicate, - unsigned int* stat_rx_data_pdu, - unsigned int* stat_rx_data_bytes, - unsigned int* stat_rx_data_pdu_dropped, - unsigned int* stat_rx_data_bytes_dropped, - unsigned int* stat_rx_data_pdu_out_of_window, - unsigned int* stat_rx_data_bytes_out_of_window, - unsigned int* stat_rx_control_pdu, - unsigned int* stat_rx_control_bytes, - unsigned int* stat_timer_reordering_timed_out, - unsigned int* stat_timer_poll_retransmit_timed_out, - unsigned int* stat_timer_status_prohibit_timed_out) -* \brief Request TX and RX statistics of a RLC AM protocol instance. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[out] stat_tx_pdcp_sdu Number of SDUs coming from upper layers. -* \param[out] stat_tx_pdcp_bytes Number of bytes coming from upper layers. -* \param[out] stat_tx_pdcp_sdu_discarded Number of discarded SDUs coming from upper layers. -* \param[out] stat_tx_pdcp_bytes_discarded Number of discarded bytes coming from upper layers. -* \param[out] stat_tx_data_pdu Number of transmitted data PDUs to lower layers. -* \param[out] stat_tx_data_bytes Number of transmitted data bytes to lower layers. -* \param[out] stat_tx_retransmit_pdu_by_status Number of re-transmitted data PDUs due to status reception. -* \param[out] stat_tx_retransmit_bytes_by_status Number of re-transmitted data bytes due to status reception. -* \param[out] stat_tx_retransmit_pdu Number of re-transmitted data PDUs to lower layers. -* \param[out] stat_tx_retransmit_bytes Number of re-transmitted data bytes to lower layers. -* \param[out] stat_tx_control_pdu Number of transmitted control PDUs to lower layers. -* \param[out] stat_tx_control_bytes Number of transmitted control bytes to lower layers. -* \param[out] stat_rx_pdcp_sdu Number of SDUs delivered to upper layers. -* \param[out] stat_rx_pdcp_bytes Number of bytes delivered to upper layers. -* \param[out] stat_rx_data_pdus_duplicate Number of duplicate PDUs received. -* \param[out] stat_rx_data_bytes_duplicate Number of duplicate bytes received. -* \param[out] stat_rx_data_pdu Number of received PDUs from lower layers. -* \param[out] stat_rx_data_bytes Number of received bytes from lower layers. -* \param[out] stat_rx_data_pdu_dropped Number of received PDUs from lower layers, then dropped. -* \param[out] stat_rx_data_bytes_dropped Number of received bytes from lower layers, then dropped. -* \param[out] stat_rx_data_pdu_out_of_window Number of data PDUs received out of the receive window. -* \param[out] stat_rx_data_bytes_out_of_window Number of data bytes received out of the receive window. -* \param[out] stat_rx_control_pdu Number of control PDUs received. -* \param[out] stat_rx_control_bytes Number of control bytes received. -* \param[out] stat_timer_reordering_timed_out Number of times the timer "reordering" has timed-out. -* \param[out] stat_timer_poll_retransmit_timed_out Number of times the timer "poll_retransmit" has timed-out. -* \param[out] stat_timer_status_prohibit_timed_out Number of times the timer "status_prohibit" has timed-out. -*/ -void rlc_am_stat_req ( - const protocol_ctxt_t* const ctxtP, - rlc_am_entity_t * const rlc_pP, - unsigned int* stat_tx_pdcp_sdu, - unsigned int* stat_tx_pdcp_bytes, - unsigned int* stat_tx_pdcp_sdu_discarded, - unsigned int* stat_tx_pdcp_bytes_discarded, - unsigned int* stat_tx_data_pdu, - unsigned int* stat_tx_data_bytes, - unsigned int* stat_tx_retransmit_pdu_by_status, - unsigned int* stat_tx_retransmit_bytes_by_status, - unsigned int* stat_tx_retransmit_pdu, - unsigned int* stat_tx_retransmit_bytes, - unsigned int* stat_tx_control_pdu, - unsigned int* stat_tx_control_bytes, - unsigned int* stat_rx_pdcp_sdu, - unsigned int* stat_rx_pdcp_bytes, - unsigned int* stat_rx_data_pdus_duplicate, - unsigned int* stat_rx_data_bytes_duplicate, - unsigned int* stat_rx_data_pdu, - unsigned int* stat_rx_data_bytes, - unsigned int* stat_rx_data_pdu_dropped, - unsigned int* stat_rx_data_bytes_dropped, - unsigned int* stat_rx_data_pdu_out_of_window, - unsigned int* stat_rx_data_bytes_out_of_window, - unsigned int* stat_rx_control_pdu, - unsigned int* stat_rx_control_bytes, - unsigned int* stat_timer_reordering_timed_out, - unsigned int* stat_timer_poll_retransmit_timed_out, - unsigned int* stat_timer_status_prohibit_timed_out); - -/*! \fn void rlc_am_get_pdus (const protocol_ctxt_t* const ctxtP, void * const rlc_pP) -* \brief Request the segmentation of SDUs based on status previously sent by MAC. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void -rlc_am_get_pdus ( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP -); - -/*! \fn void rlc_am_rx (const protocol_ctxt_t* const ctxtP,void * const rlc_pP, struct mac_data_ind data_indication) -* \brief Process the received PDUs from lower layer. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] data_indication PDUs from MAC. -*/ -void rlc_am_rx (const protocol_ctxt_t* const ctxtP,void * const rlc_pP, struct mac_data_ind); - -/*! \fn struct mac_status_resp rlc_am_mac_status_indication (const protocol_ctxt_t* const ctxtP,void * const rlc_pP, struct mac_status_ind tx_statusP,const eNB_flag_t enb_flagP) -* \brief Request the maximum number of bytes that can be served by RLC instance to MAC and fix the amount of bytes requested by MAC for next RLC transmission. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] tx_statusP Transmission status given by MAC on previous MAC transmission of the PDU. -* \param[in] enb_flagP eNB or UE flag indication. -* \return The maximum number of bytes that can be served by RLC instance to MAC. -*/ -struct mac_status_resp rlc_am_mac_status_indication (const protocol_ctxt_t* const ctxtP, void * const rlc_pP, struct mac_status_ind tx_statusP,const eNB_flag_t enb_flagP); - -/*! \fn struct mac_data_req rlc_am_mac_data_request (const protocol_ctxt_t* const ctxtP,void * const rlc_pP,const eNB_flag_t enb_flagP) -* \brief Gives PDUs to lower layer MAC. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] enb_flagP eNB or UE flag -* \return A PDU of the previously requested number of bytes, and the updated maximum number of bytes that can be served by RLC instance to MAC for next RLC transmission. -*/ -struct mac_data_req rlc_am_mac_data_request (const protocol_ctxt_t* const ctxtP,void * const rlc_pP,const eNB_flag_t enb_flagP); - -/*! \fn void rlc_am_mac_data_indication (const protocol_ctxt_t* const ctxtP,void * const rlc_pP, struct mac_data_ind data_indP) -* \brief Receive PDUs from lower layer MAC. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] data_indP PDUs from MAC. -*/ -void rlc_am_mac_data_indication (const protocol_ctxt_t* const ctxtP,void * const rlc_pP, struct mac_data_ind data_indP); - -/*! \fn uint32_t rlc_am_get_buffer_occupancy_in_bytes (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP) -* \brief Get Tx Buffer Occupancy. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -uint32_t rlc_am_get_buffer_occupancy_in_bytes (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP); - -/*! \fn void rlc_am_data_req (const protocol_ctxt_t* const ctxtP,void * const rlc_pP, mem_block_t *sduP) -* \brief Interface with higher layers, buffer higher layer SDUS for transmission. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] sduP SDU. (A struct rlc_am_data_req is mapped on sduP->data.) -*/ -void rlc_am_data_req (const protocol_ctxt_t* const ctxtP,void * const rlc_pP, mem_block_t *sduP); -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_constants.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_constants.h deleted file mode 100644 index 674b8c244eef590fb830e39053fdd6837b41c85c..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_constants.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_constants.h -* \brief This file defines constant values used in RLC AM. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** -* @addtogroup _rlc_am_internal_impl_ -* @{ -*/ -#ifndef __RLC_AM_CONSTANT_H__ -# define __RLC_AM_CONSTANT_H__ - -/** The sequence numbering modulo (10 bits). */ -# define RLC_AM_SN_MODULO 1024 - -/** The sequence numbering binary mask (10 bits). */ -# define RLC_AM_SN_MASK 0x3FF - -/** FROM Spec: This constant is used by both the transmitting side and the receiving side of each AM RLC entity to calculate VT(MS) from VT(A), and VR(MR) from VR(R). AM_Window_Size = 512.. */ -# define RLC_AM_WINDOW_SIZE 512 - -/** Max number of bytes of incoming SDUs from upper layer that can be buffered in a RLC AM protocol instance. */ -# define RLC_AM_SDU_DATA_BUFFER_SIZE 64*1024 - -/** Max number of incoming SDUs from upper layer that can be buffered in a RLC AM protocol instance. */ -# define RLC_AM_SDU_CONTROL_BUFFER_SIZE 1024 - -/** Size of the retransmission buffer (number of PDUs). */ -# define RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE RLC_AM_WINDOW_SIZE - -/** PDU minimal header size in bytes. */ -# define RLC_AM_HEADER_MIN_SIZE 2 - -/** PDU Segment minimal header size in bytes = PDU header + SOStart + SOEnd. */ -# define RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE 4 - -/** If we want to send a segment of a PDU, then the min transport block size requested by MAC should be this amount. */ -# define RLC_AM_MIN_SEGMENT_SIZE_REQUEST 8 - -/** Max SDUs that can fit in a PDU. */ -# define RLC_AM_MAX_SDU_IN_PDU 128 - -/** Max fragments for a SDU. */ -# define RLC_AM_MAX_SDU_FRAGMENTS 32 - -/** Max Negative Acknowledgment SN (NACK_SN) fields in a STATUS PDU. */ -# define RLC_AM_MAX_NACK_IN_STATUS_PDU 1023 - -/** Max holes created by NACK_SN with segment offsets for a PDU in the retransmission buffer. */ -# define RLC_AM_MAX_HOLES_REPORT_PER_PDU 16 -/** @} */ - -#define RLC_AM_POLL_PDU_INFINITE 0xFFFF -#define RLC_AM_POLL_BYTE_INFINITE 0xFFFFFFFF - -/* MACRO DEFINITIONS */ - -#define RLC_AM_NEXT_SN(sn) (((sn)+1) & (RLC_AM_SN_MASK)) -#define RLC_AM_PREV_SN(sn) (((sn)+(RLC_AM_SN_MODULO)-1) & (RLC_AM_SN_MASK)) - -#define RLC_DIFF_SN(sn,snref,modulus) ((sn+(modulus)-snref) & ((modulus)-1)) -#define RLC_SN_IN_WINDOW(sn,snref,modulus) ((RLC_DIFF_SN(sn,snref,modulus)) < ((modulus) >> 1)) - -#define RLC_AM_DIFF_SN(sn,snref) (RLC_DIFF_SN(sn,snref,RLC_AM_SN_MODULO)) -#define RLC_AM_SN_IN_WINDOW(sn,snref) (RLC_SN_IN_WINDOW(sn,snref,RLC_AM_SN_MODULO)) - -#define RLC_SET_BIT(x,offset) ((x) |= (1 << (offset))) -#define RLC_GET_BIT(x,offset) (((x) & (1 << (offset))) >> (offset)) -#define RLC_CLEAR_BIT(x,offset) ((x) &= ~(1 << (offset))) - -#define RLC_SET_EVENT(x,event) ((x) |= (event)) -#define RLC_GET_EVENT(x,event) ((x) & (event)) -#define RLC_CLEAR_EVENT(x,event) ((x) &= (~(event))) - -/* Common to Data and Status PDU */ -#define RLC_AM_SN_BITS 10 -#define RLC_AM_PDU_D_C_BITS 1 -#define RLC_AM_PDU_E_BITS 1 -#define RLC_AM_PDU_FI_BITS 2 -#define RLC_AM_PDU_POLL_BITS 1 -#define RLC_AM_PDU_RF_BITS 1 - - -#define RLC_AM_LI_BITS 11 -#define RLC_AM_LI_MASK 0x7FF - - -/* AM Data PDU */ -#define RLC_AM_PDU_E_OFFSET 2 -#define RLC_AM_PDU_FI_OFFSET (RLC_AM_PDU_E_OFFSET + RLC_AM_PDU_E_BITS) -#define RLC_AM_PDU_POLL_OFFSET (RLC_AM_PDU_FI_OFFSET + RLC_AM_PDU_FI_BITS) -#define RLC_AM_PDU_RF_OFFSET (RLC_AM_PDU_POLL_OFFSET + RLC_AM_PDU_POLL_BITS) -#define RLC_AM_PDU_D_C_OFFSET (RLC_AM_PDU_RF_OFFSET + RLC_AM_PDU_RF_BITS) - -#define RLC_AM_PDU_GET_FI_START(px) (RLC_GET_BIT((px),RLC_AM_PDU_FI_OFFSET + 1)) -#define RLC_AM_PDU_GET_FI_END(px) (RLC_GET_BIT((px),RLC_AM_PDU_FI_OFFSET)) - -#define RLC_AM_PDU_GET_LI(x,offset) (((x) >> (offset)) & RLC_AM_LI_MASK) -#define RLC_AM_PDU_SET_LI(x,li,offset) ((x) |= (((li) & RLC_AM_LI_MASK) << (offset))) - -#define RLC_AM_PDU_SET_E(px) (RLC_SET_BIT((px),RLC_AM_PDU_E_OFFSET)) -#define RLC_AM_PDU_SET_D_C(px) (RLC_SET_BIT((px),RLC_AM_PDU_D_C_OFFSET)) -#define RLC_AM_PDU_SET_RF(px) (RLC_SET_BIT((px),RLC_AM_PDU_RF_OFFSET)) -#define RLC_AM_PDU_SET_POLL(px) (RLC_SET_BIT((px),RLC_AM_PDU_POLL_OFFSET)) -#define RLC_AM_PDU_CLEAR_POLL(px) (RLC_CLEAR_BIT((px),RLC_AM_PDU_POLL_OFFSET)) - -#define RLC_AM_PDU_SEGMENT_SO_LENGTH 15 -#define RLC_AM_PDU_SEGMENT_SO_BYTES 2 -#define RLC_AM_PDU_SEGMENT_SO_OFFSET 0 -#define RLC_AM_PDU_LSF_OFFSET (RLC_AM_PDU_SEGMENT_SO_OFFSET + RLC_AM_PDU_SEGMENT_SO_LENGTH) - -#define RLC_AM_PDU_SET_LSF(px) (RLC_SET_BIT((px),RLC_AM_PDU_LSF_OFFSET)) - -#define RLC_AM_HEADER_LI_LENGTH(li) ((li) + ((li)>>1) + ((li)&1)) -#define RLC_AM_PDU_SEGMENT_HEADER_SIZE(numLis) (RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE + RLC_AM_HEADER_LI_LENGTH(numLis)) - -/* STATUS PDU */ -#define RLC_AM_STATUS_PDU_CPT_STATUS 0 - -#define RLC_AM_STATUS_PDU_CPT_OFFSET 4 -#define RLC_AM_STATUS_PDU_CPT_LENGTH 3 - -#define RLC_AM_STATUS_PDU_ACK_SN_OFFSET 2 - -#define RLC_AM_STATUS_PDU_SO_LENGTH 15 - -#define RLC_AM_STATUS_PDU_SO_END_ALL_BYTES 0x7FFF - - -/* Uplink STATUS PDU trigger events */ -#define RLC_AM_STATUS_NOT_TRIGGERED 0 -#define RLC_AM_STATUS_TRIGGERED_POLL 0x01 /* Status Report is triggered by a received poll */ -#define RLC_AM_STATUS_TRIGGERED_T_REORDERING 0x02 /* Status Report is triggered by Timer Reordering Expiry */ -#define RLC_AM_STATUS_TRIGGERED_DELAYED 0x10 /* Status is delayed until SN(receivedPoll) < VR(MS) */ -#define RLC_AM_STATUS_PROHIBIT 0x20 /* TimerStatusProhibit still running */ -#define RLC_AM_STATUS_NO_TX_MASK (RLC_AM_STATUS_PROHIBIT | RLC_AM_STATUS_TRIGGERED_DELAYED) - -/* Status triggered (bit 5-7) will be concatenated with Poll triggered (bit 0-4) for RLCdec. RLC_AM_STATUS_TRIGGERED_DELAYED is not recorded. */ -#define RLC_AM_SET_STATUS(x,event) (RLC_SET_EVENT(x,event)) -#define RLC_AM_GET_STATUS(x,event) (RLC_GET_EVENT(x,event)) -#define RLC_AM_CLEAR_STATUS(x,event) (RLC_CLEAR_EVENT(x,event)) -#define RLC_AM_CLEAR_ALL_STATUS(x) ((x) = (RLC_AM_STATUS_NOT_TRIGGERED)) - - -#endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h deleted file mode 100644 index e6bcd0f4ba6c60a38e1e9f3996d0d25fdecc8e86..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_entity.h -* \brief This file defines the RLC AM variables stored in a struct called rlc_am_entity_t. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note The rlc_am_entity_t structure store protocol variables, statistic variables, allocation variables, buffers and other miscellaneous variables. -* \bug -* \warning -*/ -/** @defgroup _rlc_am_internal_impl_ RLC AM Layer Internal Reference Implementation -* @ingroup _rlc_am_impl_ -* @{ -*/ - -# ifndef __RLC_AM_ENTITY_H__ -# define __RLC_AM_ENTITY_H__ -//----------------------------------------------------------------------------- -# include <pthread.h> -# include "platform_types.h" -#include "common/platform_constants.h" -# include "list.h" -# include "rlc_primitives.h" -# include "rlc_def_lte.h" -# include "rlc_def.h" -# include "rlc_am_structs.h" -# include "rlc_am_constants.h" -//----------------------------------------------------------------------------- -/*! \struct rlc_am_entity_t -* \brief Structure containing a RLC AM instance protocol variables, statistic variables, allocation variables, buffers and other miscellaneous variables. -*/ -typedef struct rlc_am_entity_s { - - - rb_id_t rb_id; /*!< \brief Radio bearer identifier, for statistics and trace purpose. */ - logical_chan_id_t channel_id; /*!< \brief Transport channel identifier. */ - bool is_data_plane; /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */ - - rlc_buffer_occupancy_t sdu_buffer_occupancy; /*!< \brief Number of bytes of unsegmented SDUs. */ - rlc_buffer_occupancy_t status_buffer_occupancy; /*!< \brief Number of bytes of control PDUs waiting for transmission. */ - - rlc_am_control_pdu_info_t control_pdu_info; - - //--------------------------------------------------------------------- - // TX BUFFERS - //--------------------------------------------------------------------- - //pthread_spinlock_t lock_input_sdus; - pthread_mutex_t lock_input_sdus; - rlc_am_tx_sdu_management_t *input_sdus; /*!< \brief Input SDU buffer (for SDUs coming from upper layers). */ - signed int nb_sdu; /*!< \brief Total number of valid rlc_am_tx_sdu_management_t in input_sdus[]. */ - signed int nb_sdu_no_segmented; /*!< \brief Total number of SDUs not segmented and partially segmented. nb_sdu_no_segmented = next_sdu_index - current_sdu_index */ - signed int next_sdu_index; /*!< \brief Next SDU index in input_sdus array where for a new incoming SDU. */ - signed int current_sdu_index; /*!< \brief Current SDU index in input_sdus array to be segmented which is not segmented or partially segmented. */ - - - rlc_am_tx_data_pdu_management_t *tx_data_pdu_buffer; /*!< \brief Transmission PDU data buffer. Used also for retransmissions */ - signed int retrans_num_pdus; /*!< \brief Number of PDUs in the retransmission buffer. */ - signed int retrans_num_bytes_to_retransmit; /*!< \brief Number of bytes in the retransmission buffer to be retransmitted. Only payload is taken into account */ - bool force_poll; /*!< \brief force poll due to t_poll_retransmit time-out. */ - - //--------------------------------------------------------------------- - // RX BUFFERS - //--------------------------------------------------------------------- - list2_t receiver_buffer; /*!< \brief Receiver buffer implemented with a list. */ - mem_block_t *output_sdu_in_construction; /*!< \brief Memory area where a complete SDU is reassemblied before being send to upper layers. */ - sdu_size_t output_sdu_size_to_write; /*!< \brief Size of the reassemblied SDU. */ - - - //--------------------------------------------------------------------- - // PROTOCOL VARIABLES - //--------------------------------------------------------------------- - rlc_protocol_state_t protocol_state; /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE. */ - //----------------------------- - // TX STATE VARIABLES - //----------------------------- - rlc_usn_t - vt_a; /*!< \brief Acknowledgement state variable. This state variable holds the value of the SN of the next AMD PDU for which a positive acknowledgment is to be received in-sequence, and it serves as the lower edge of the transmitting window. It is initially set to 0, and is updated whenever the AM RLC entity receives a positive acknowledgment for an AMD PDU with SN = VT(A).*/ - rlc_usn_t vt_ms; /*!< \brief Maximum send state variable. This state variable equals VT(A) + AM_Window_Size, and it serves as the higher edge of the transmitting window. */ - rlc_usn_t - vt_s; /*!< \brief Send state variable. This state variable holds the value of the SN to be assigned for the next newly generated AMD PDU. It is initially set to 0, and is updated whenever the AM RLC entity delivers an AMD PDU with SN = VT(S).*/ - rlc_usn_t - poll_sn; /*!< \brief Poll send state variable. This state variable holds the value of VT(S)-1 upon the most recent transmission of a RLC data PDU with the poll bit set to “1â€. It is initially set to 0.*/ - - //----------------------------- - // RX STATE VARIABLES - //----------------------------- - rlc_usn_t - vr_r; /*!< \brief Receive state variable. This state variable holds the value of the SN following the last in-sequence completely received AMD PDU, and it serves as the lower edge of the receiving window. It is initially set to 0, and is updated whenever the AM RLC entity receives an AMD PDU with SN = VR(R). */ - rlc_usn_t - vr_mr; /*!< \brief Maximum acceptable receive state variable. This state variable equals VR(R) + AM_Window_Size, and it holds the value of the SN of the first AMD PDU that is beyond the receiving window and serves as the higher edge of the receiving window. */ - rlc_usn_t vr_x; /*!< \brief t-Reordering state variable. This state variable holds the value of the SN following the SN of the RLC data PDU which triggered t-Reordering. */ - rlc_usn_t - vr_ms; /*!< \brief Maximum STATUS transmit state variable. This state variable holds the highest possible value of the SN which can be indicated by “ACK_SN†when a STATUS PDU needs to be constructed. It is initially set to 0. */ - rlc_usn_t - vr_h; /*!< \brief Highest received state variable. This state variable holds the value of the SN following the SN of the RLC data PDU with the highest SN among received RLC data PDUs. It is initially set to 0. */ - - //----------------------------- - // TIMERS CONFIGURED BY RRC - //----------------------------- - rlc_am_timer_t t_poll_retransmit; /*!< \brief This timer is used by the transmitting side of an AM RLC entity in order to retransmit a poll. */ - rlc_am_timer_t - t_reordering; /*!< \brief This timer is used by the receiving side of an AM RLC entity and receiving UM RLC entity in order to detect loss of RLC PDUs at lower layer (see sub clauses 5.1.2.2 and 5.1.3.2). If t-Reordering is running, t-Reordering shall not be started additionally, i.e. only one t-Reordering per RLC entity is running at a given time. */ - rlc_am_timer_t t_status_prohibit; /*!< \brief This timer is used by the receiving side of an AM RLC entity in order to prohibit transmission of a STATUS PDU. */ - - //----------------------------- - // COUNTERS - //----------------------------- - unsigned int c_pdu_without_poll; /*!< \brief This counter is initially set to 0. It counts the number of AMD PDUs sent since the most recent poll bit was transmitted. */ - unsigned int c_byte_without_poll;/*!< \brief This counter is initially set to 0. It counts the number of data bytes sent since the most recent poll bit was transmitted. */ - - //----------------------------- - // PARAMETERS CONFIGURED BY RRC - //----------------------------- - uint16_t max_retx_threshold; /*!< \brief This parameter is used by the transmitting side of each AM RLC entity to limit the number of retransmissions of an AMD PDU. */ - uint16_t poll_pdu; /*!< \brief This parameter is used by the transmitting side of each AM RLC entity to trigger a poll for every pollPDU PDUs. */ - uint32_t poll_byte; /*!< \brief This parameter is used by the transmitting side of each AM RLC entity to trigger a poll for every pollByte bytes. */ - - //--------------------------------------------------------------------- - // STATISTICS - //--------------------------------------------------------------------- - unsigned int stat_tx_pdcp_sdu; /*!< \brief Number of SDUs received from upper layers. */ - unsigned int stat_tx_pdcp_bytes; /*!< \brief Number of SDU bytes received from upper layers. */ - unsigned int stat_tx_pdcp_sdu_discarded; /*!< \brief Number of SDUs received from upper layers that have been discarded. */ - unsigned int stat_tx_pdcp_bytes_discarded; /*!< \brief Number of SDU bytes received from upper layers that have been discarded. */ - - unsigned int stat_tx_data_pdu; /*!< \brief For statistic report, number of transmitted PDUs to lower layers. */ - unsigned int stat_tx_data_bytes; /*!< \brief For statistic report, number of transmitted bytes to lower layers. */ - unsigned int stat_tx_retransmit_pdu_by_status; /*!< \brief Not updated. */ - unsigned int stat_tx_retransmit_bytes_by_status; /*!< \brief Not updated. */ - unsigned int stat_tx_retransmit_pdu; /*!< \brief Not updated. */ - unsigned int stat_tx_retransmit_bytes; /*!< \brief Not updated. */ - unsigned int stat_tx_control_pdu; /*!< \brief Not updated. */ - unsigned int stat_tx_control_bytes; /*!< \brief Not updated. */ - - unsigned int stat_rx_pdcp_sdu; /*!< \brief For statistic report, number of reassemblied SDUs, sent to upper layers. */ - unsigned int stat_rx_pdcp_bytes; /*!< \brief For statistic report, number of reassemblied bytes, sent to upper layers. */ - unsigned int stat_rx_data_pdus_duplicate; /*!< \brief For statistic report, number of received duplicated PDUs from lower layers. */ - unsigned int stat_rx_data_bytes_duplicate; /*!< \brief For statistic report, number of received duplicated bytes from lower layers. */ - unsigned int stat_rx_data_pdu; /*!< \brief For statistic report, number of received PDUs from lower layers. */ - unsigned int stat_rx_data_bytes; /*!< \brief For statistic report, number of received bytes from lower layers. */ - unsigned int stat_rx_data_pdu_dropped; /*!< \brief For statistic report, number of dropped received PDUs from lower layers. Does not include out of window stat. */ - unsigned int stat_rx_data_bytes_dropped; /*!< \brief For statistic report, number of dropped received bytes from lower layers. Does not include out of window stat. */ - unsigned int stat_rx_data_pdu_out_of_window; /*!< \brief Number of data PDUs received out of the receive window. */ - unsigned int stat_rx_data_bytes_out_of_window; /*!< \brief Number of data bytes received out of the receive window. */ - unsigned int stat_rx_control_pdu; /*!< \brief Number of control PDUs received. */ - unsigned int stat_rx_control_bytes; /*!< \brief Number of control bytes received. */ - - unsigned int stat_timer_reordering_timed_out; - unsigned int stat_timer_poll_retransmit_timed_out; - unsigned int stat_timer_status_prohibit_timed_out; - - //--------------------------------------------------------------------- - // OUTPUTS - //--------------------------------------------------------------------- - sdu_size_t nb_bytes_requested_by_mac; /*!< \brief Number of remaining bytes available for transmission of any RLC PDU indicated by lower layer */ - list_t pdus_to_mac_layer; /*!< \brief PDUs buffered for transmission to MAC layer. */ - list_t control_pdu_list; /*!< \brief Control PDUs buffered for transmission to MAC layer. */ - list_t segmentation_pdu_list; /*!< \brief List of "freshly" segmented PDUs. */ - - uint8_t status_requested; /*!< \brief Status bitmap requested by peer. */ - rlc_sn_t sn_status_triggered_delayed; /*!< \brief SN of the last received poll for which Status is delayed until SN is out of Rx Window. */ - uint32_t last_absolute_subframe_status_indication; /*!< \brief The last absolute subframe number a MAC status indication has been received by RLC. */ - //----------------------------- - // buffer occupancy measurements sent to MAC - //----------------------------- - // note occupancy of other buffers is deducted from nb elements in lists - rlc_buffer_occupancy_t buffer_occupancy_retransmission_buffer; /*!< \brief Number of PDUs. */ - - bool initialized; /*!< \brief Boolean for rlc_am_entity_t struct initialization. */ - bool configured; /*!< \brief Boolean for rlc_am_entity_t struct configuration. */ -} rlc_am_entity_t; -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c deleted file mode 100644 index af2cbb97bdb24d060a2d06558a883a3eb02600f8..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - rlc_am_in_sdu.c - - ------------------- - AUTHOR : Lionel GAUTHIER - COMPANY : EURECOM - EMAIL : Lionel.Gauthier@eurecom.fr - ***************************************************************************/ -#define RLC_AM_MODULE 1 -#define RLC_AM_IN_SDU_C 1 -//----------------------------------------------------------------------------- -#include "rlc_am.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" - -#define TRACE_RLC_AM_FREE_SDU 0 -//----------------------------------------------------------------------------- -void rlc_am_free_in_sdu( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlcP, - const unsigned int index_in_bufferP) -{ - if (index_in_bufferP <= RLC_AM_SDU_CONTROL_BUFFER_SIZE) { - /* BugFix: SDU shall have been already freed during initial PDU segmentation or concatenation !! */ -//Assertion(eNB)_PRAN_DesignDocument_annex No.761 - if(rlcP->input_sdus[index_in_bufferP].mem_block != NULL) - { - LOG_E(RLC, "RLC AM Tx SDU Conf: Data Part is not empty index=%d LcId=%d\n", - index_in_bufferP,rlcP->channel_id); - return; - } -/* - AssertFatal(rlcP->input_sdus[index_in_bufferP].mem_block == NULL, "RLC AM Tx SDU Conf: Data Part is not empty index=%d LcId=%d\n", - index_in_bufferP,rlcP->channel_id); -*/ - /* - if (rlcP->input_sdus[index_in_bufferP].mem_block != NULL) { - free_mem_block(rlcP->input_sdus[index_in_bufferP].mem_block, __func__); - rlcP->input_sdus[index_in_bufferP].mem_block = NULL; - rlcP->nb_sdu_no_segmented -= 1; - rlcP->input_sdus[index_in_bufferP].sdu_remaining_size = 0; - } - */ - - rlcP->nb_sdu -= 1; - memset(&rlcP->input_sdus[index_in_bufferP], 0, sizeof(rlc_am_tx_sdu_management_t)); - rlcP->input_sdus[index_in_bufferP].flags.transmitted_successfully = 1; - - // case when either one SDU needs to be removed from segmentation or SDU buffer is full - if (rlcP->current_sdu_index == index_in_bufferP) { - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; - } - - // wrapping and reset current_sdu_index to next_sdu_index when all transmitted SDUs have been acknowledged - while ((rlcP->current_sdu_index != rlcP->next_sdu_index) && - (rlcP->input_sdus[rlcP->current_sdu_index].flags.transmitted_successfully == 1)) { - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; - } - } - -#if TRACE_RLC_AM_FREE_SDU - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[FREE SDU] SDU INDEX %03u current_sdu_index=%u next_sdu_index=%u nb_sdu_no_segmented=%u\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlcP), - index_in_bufferP, - rlcP->current_sdu_index, - rlcP->next_sdu_index, - rlcP->nb_sdu_no_segmented); -#endif -} -// called when segmentation is done -//----------------------------------------------------------------------------- -void -rlc_am_free_in_sdu_data( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlcP, - const unsigned int index_in_bufferP) -{ - if (index_in_bufferP <= RLC_AM_SDU_CONTROL_BUFFER_SIZE) { - if (rlcP->input_sdus[index_in_bufferP].mem_block != NULL) { - free_mem_block(rlcP->input_sdus[index_in_bufferP].mem_block, __func__); - rlcP->input_sdus[index_in_bufferP].mem_block = NULL; - rlcP->input_sdus[index_in_bufferP].sdu_remaining_size = 0; - rlcP->nb_sdu_no_segmented -= 1; - } - } -} -//----------------------------------------------------------------------------- -signed int -rlc_am_in_sdu_is_empty( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlcP) -{ - if (rlcP->nb_sdu == 0) { - return 1; - } - - return 0; -} - -// called when PDU is ACKED -//----------------------------------------------------------------------------- -void -rlc_am_pdu_sdu_data_cnf( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP, - const rlc_sn_t snP) -{ - int pdu_sdu_index; - int 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); - if(sdu_index < 0 || sdu_index >= RLC_AM_SDU_CONTROL_BUFFER_SIZE) { - LOG_E(RLC, "sdu_index error. sdu_index %d, pdu_sdu_index %d\n", sdu_index, pdu_sdu_index); - continue; - } - - rlc_pP->input_sdus[sdu_index].nb_pdus_ack += 1; - - if ((rlc_pP->input_sdus[sdu_index].nb_pdus_ack == rlc_pP->input_sdus[sdu_index].nb_pdus) && - (rlc_pP->input_sdus[sdu_index].sdu_remaining_size == 0)) { - #if TEST_RLC_AM - rlc_am_v9_3_0_test_data_conf ( - rlc_pP->module_id, - rlc_pP->rb_id, - rlc_pP->input_sdus[sdu_index].mui, - RLC_SDU_CONFIRM_YES); - #else - rlc_data_conf( - ctxt_pP, - rlc_pP->rb_id, - rlc_pP->input_sdus[sdu_index].mui, - RLC_SDU_CONFIRM_YES, - rlc_pP->is_data_plane); - #endif - rlc_am_free_in_sdu(ctxt_pP, rlc_pP, sdu_index); - } - } -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.h deleted file mode 100644 index bc97490c905991cc30c69b350d59682877e0e77f..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_in_sdu.h -* \brief This file defines the prototypes of the utility functions manipulating the incoming SDU buffer. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_internal_input_sdu_impl_ RLC AM Input SDU buffer Internal Reference Implementation -* @ingroup _rlc_am_internal_impl_ -* @{ -*/ -# ifndef __RLC_AM_IN_SDU_H__ -# define __RLC_AM_IN_SDU_H__ -/*! \fn void rlc_am_free_in_sdu (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *rlcP, unsigned int index_in_bufferP) -* \brief Free a higher layer SDU stored in input_sdus[] buffer. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] index_in_bufferP Position index of the SDU. -* \note Update also the RLC AM instance variables nb_sdu, current_sdu_index, nb_sdu_no_segmented. -*/ -void rlc_am_free_in_sdu (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *rlcP, unsigned int index_in_bufferP); - - -/*! \fn void rlc_am_free_in_sdu_data (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *rlcP, unsigned int index_in_bufferP) -* \brief Free a higher layer SDU data part, the SDU is stored in input_sdus[] buffer. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] index_in_bufferP Position index of the SDU. -* \note This procedure is called when the SDU segmentation is done for this SDU. Update also the RLC AM instance variable nb_sdu_no_segmented. -*/ -void rlc_am_free_in_sdu_data (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *rlcP, unsigned int index_in_bufferP); - - -/*! \fn signed int rlc_am_in_sdu_is_empty(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *rlcP) -* \brief Indicates if the input SDU buffer for incoming higher layer SDUs is empty or not. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \return 1 if the buffer is empty, else 0. -*/ -signed int rlc_am_in_sdu_is_empty(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *rlcP); - -/*! \fn void rlc_am_pdu_sdu_data_cnf(const protocol_ctxt_t* const ctxt_pP,rlc_am_entity_t* const rlc_pP,const rlc_sn_t snP) -* \brief Process SDU cnf of a ACKED PDU for all SDUs concatenated in this PDU. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] snP Sequence number of the PDU. -*/ -void rlc_am_pdu_sdu_data_cnf(const protocol_ctxt_t* const ctxt_pP,rlc_am_entity_t* const rlc_pP,const rlc_sn_t snP); -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c deleted file mode 100644 index 8ff29fa44bfe944e1c859ec79e04a0fb5bcec5e5..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_INIT_C 1 -#include <string.h> -//----------------------------------------------------------------------------- -#include "rlc_am.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" -//----------------------------------------------------------------------------- -void -rlc_am_init( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP) -{ - if (rlc_pP->initialized == true) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM INIT] INITIALIZATION ALREADY DONE, DOING NOTHING\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - } else { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM INIT] INITIALIZATION: STATE VARIABLES, BUFFERS, LISTS\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - memset(rlc_pP, 0, sizeof(rlc_am_entity_t)); - - list2_init(&rlc_pP->receiver_buffer, "RX BUFFER"); - list_init(&rlc_pP->pdus_to_mac_layer, "PDUS TO MAC"); - list_init(&rlc_pP->control_pdu_list, "CONTROL PDU LIST"); - list_init(&rlc_pP->segmentation_pdu_list, "SEGMENTATION PDU LIST"); - //LOG_D(RLC,"RLC_AM_SDU_CONTROL_BUFFER_SIZE %d sizeof(rlc_am_tx_sdu_management_t) %d \n", RLC_AM_SDU_CONTROL_BUFFER_SIZE, sizeof(rlc_am_tx_sdu_management_t)); - - pthread_mutex_init(&rlc_pP->lock_input_sdus, NULL); - rlc_pP->input_sdus = calloc(1, RLC_AM_SDU_CONTROL_BUFFER_SIZE*sizeof(rlc_am_tx_sdu_management_t)); -//#warning "cast the rlc retrans buffer to uint32" - // rlc_pP->tx_data_pdu_buffer = calloc(1, (uint16_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof(rlc_am_tx_data_pdu_management_t))); - rlc_pP->tx_data_pdu_buffer = calloc(1, (uint32_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof( - rlc_am_tx_data_pdu_management_t))); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM INIT] input_sdus[] = %p element size=%zu\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->input_sdus, - sizeof(rlc_am_tx_sdu_management_t)); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM INIT] tx_data_pdu_buffer[] = %p element size=%zu\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->tx_data_pdu_buffer, - sizeof(rlc_am_tx_data_pdu_management_t)); - - // TX state variables - //rlc_pP->vt_a = 0; - rlc_pP->vt_ms = rlc_pP->vt_a + RLC_AM_WINDOW_SIZE; - //rlc_pP->vt_s = 0; - //rlc_pP->poll_sn = 0; - // TX counters - //rlc_pP->c_pdu_without_poll = 0; - //rlc_pP->c_byte_without_poll = 0; - // RX state variables - //rlc_pP->vr_r = 0; - rlc_pP->vr_mr = rlc_pP->vr_r + RLC_AM_WINDOW_SIZE; - rlc_pP->vr_x = RLC_SN_UNDEFINED; - //rlc_pP->vr_ms = 0; - //rlc_pP->vr_h = 0; - rlc_pP->sn_status_triggered_delayed = RLC_SN_UNDEFINED; - - rlc_pP->last_absolute_subframe_status_indication = 0xFFFFFFFF; // any value > 1 - - rlc_pP->initialized = true; - } -} -//----------------------------------------------------------------------------- -void -rlc_am_reestablish( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP) -{ - /* - * RLC re-establishment is performed upon request by RRC, and the function - * is applicable for AM, UM and TM RLC entities. - * When RRC indicates that an RLC entity should be re-established, the RLC entity shall: - * - if it is an AM RLC entity: - * - when possible, reassemble RLC SDUs from any byte segments of AMD PDUs with SN < VR(MR) in the - * receiving side, remove RLC headers when doing so and deliver all reassembled RLC SDUs to upper layer in - * ascending order of the RLC SN, if not delivered before; - * - discard the remaining AMD PDUs and byte segments of AMD PDUs in the receiving side; - * - discard all RLC SDUs and AMD PDUs in the transmitting side; - * - discard all RLC control PDUs. - * - stop and reset all timers; - * - reset all state variables to their initial values. - */ - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM REESTABLISH] RE-INIT STATE VARIABLES, BUFFERS, LISTS\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - -//#warning TODO when possible reassemble RLC SDUs from any byte segments of AMD PDUs with SN inf VR(MR) - list2_free(&rlc_pP->receiver_buffer); - - list_free(&rlc_pP->pdus_to_mac_layer); - list_free(&rlc_pP->control_pdu_list); - list_free(&rlc_pP->segmentation_pdu_list); - - - // TX state variables - rlc_pP->vt_a = 0; - rlc_pP->vt_ms = rlc_pP->vt_a + RLC_AM_WINDOW_SIZE; - rlc_pP->vt_s = 0; - rlc_pP->poll_sn = 0; - - // TX counters - rlc_pP->c_pdu_without_poll = 0; - rlc_pP->c_byte_without_poll = 0; - - // RX state variables - rlc_pP->vr_r = 0; - rlc_pP->vr_mr = rlc_pP->vr_r + RLC_AM_WINDOW_SIZE; - rlc_pP->vr_x = RLC_SN_UNDEFINED; - rlc_pP->vr_ms = 0; - rlc_pP->vr_h = 0; - rlc_pP->sn_status_triggered_delayed = RLC_SN_UNDEFINED; - rlc_pP->status_requested = RLC_AM_STATUS_NOT_TRIGGERED; - - rlc_pP->last_absolute_subframe_status_indication = 0xFFFFFFFF; // any value > 1 - - rlc_pP->initialized = true; - -} - -//----------------------------------------------------------------------------- -void -rlc_am_cleanup( - rlc_am_entity_t* const rlc_pP -) -{ - list2_free(&rlc_pP->receiver_buffer); - list_free(&rlc_pP->pdus_to_mac_layer); - list_free(&rlc_pP->control_pdu_list); - list_free(&rlc_pP->segmentation_pdu_list); - - - if (rlc_pP->output_sdu_in_construction != NULL) { - free_mem_block(rlc_pP->output_sdu_in_construction, __func__); - rlc_pP->output_sdu_in_construction = NULL; - } - - unsigned int i; - - if (rlc_pP->input_sdus != NULL) { - for (i=0; i < RLC_AM_SDU_CONTROL_BUFFER_SIZE; i++) { - if (rlc_pP->input_sdus[i].mem_block != NULL) { - free_mem_block(rlc_pP->input_sdus[i].mem_block, __func__); - rlc_pP->input_sdus[i].mem_block = NULL; - } - } - - free(rlc_pP->input_sdus); - rlc_pP->input_sdus = NULL; - } - - pthread_mutex_destroy(&rlc_pP->lock_input_sdus); - - 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 % 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; - } - } - - free(rlc_pP->tx_data_pdu_buffer); - rlc_pP->tx_data_pdu_buffer = NULL; - } - - memset(rlc_pP, 0, sizeof(rlc_am_entity_t)); -} -//----------------------------------------------------------------------------- -void -rlc_am_configure( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - const uint16_t max_retx_thresholdP, - const uint16_t poll_pduP, - const uint16_t poll_byteP, - const uint32_t t_poll_retransmitP, - const uint32_t t_reorderingP, - const uint32_t t_status_prohibitP) -{ - if (rlc_pP->configured == true) { - LOG_I(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RECONFIGURE] max_retx_threshold %d poll_pdu %d poll_byte %d t_poll_retransmit %d t_reordering %d t_status_prohibit %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - max_retx_thresholdP, - poll_pduP, - poll_byteP, - t_poll_retransmitP, - t_reorderingP, - t_status_prohibitP); - - rlc_pP->max_retx_threshold = max_retx_thresholdP; - rlc_pP->poll_pdu = poll_pduP; - rlc_pP->poll_byte = poll_byteP; - rlc_pP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; - rlc_pP->t_poll_retransmit.ms_duration = t_poll_retransmitP; - rlc_pP->t_reordering.ms_duration = t_reorderingP; - rlc_pP->t_status_prohibit.ms_duration = t_status_prohibitP; - - } else { - LOG_I(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[CONFIGURE] max_retx_threshold %d poll_pdu %d poll_byte %d t_poll_retransmit %d t_reordering %d t_status_prohibit %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - max_retx_thresholdP, - poll_pduP, - poll_byteP, - t_poll_retransmitP, - t_reorderingP, - t_status_prohibitP); - - rlc_pP->max_retx_threshold = max_retx_thresholdP; - rlc_pP->poll_pdu = poll_pduP; - rlc_pP->poll_byte = poll_byteP; - rlc_pP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; - - - rlc_am_init_timer_poll_retransmit(ctxt_pP, rlc_pP, t_poll_retransmitP); - rlc_am_init_timer_reordering (ctxt_pP, rlc_pP, t_reorderingP); - rlc_am_init_timer_status_prohibit(ctxt_pP, rlc_pP, t_status_prohibitP); - - rlc_pP->configured = true; - } - -} -//----------------------------------------------------------------------------- -void -rlc_am_set_debug_infos( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - const srb_flag_t srb_flagP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP) -{ - rlc_pP->rb_id = rb_idP; - rlc_pP->channel_id = chan_idP; - - if (srb_flagP) { - rlc_pP->is_data_plane = 0; - } else { - rlc_pP->is_data_plane = 1; - } - - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SET DEBUG INFOS]\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h deleted file mode 100644 index df140f03266802e49be14ed19122630681ac8c90..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_init.h -* \brief This file defines the prototypes of the functions initializing a RLC AM protocol instance. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_init_impl_ RLC AM Init Reference Implementation -* @ingroup _rlc_am_impl_ -* @{ -*/ -#ifndef __RLC_AM_INIT_H__ -# define __RLC_AM_INIT_H__ - -# include "UTIL/MEM/mem_block.h" -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -#include "platform_types.h" -#include "common/platform_constants.h" -//#include "PHY/defs.h" - - -/*! \struct rlc_am_info_t -* \brief Structure containing RLC AM configuration parameters. -*/ -typedef volatile struct { - uint16_t max_retx_threshold; /*!< \brief Maximum number of retransmissions for one RLC AM PDU. */ - uint16_t poll_pdu; /*!< \brief Generate a status each poll_pdu pdu sent. */ - uint16_t poll_byte; /*!< \brief Generate a status each time poll_byte bytes have been sent. */ - uint32_t t_poll_retransmit; /*!< \brief t-PollRetransmit timer initial value. */ - uint32_t t_reordering; /*!< \brief t-Reordering timer initial value. */ - uint32_t t_status_prohibit; /*!< \brief t-StatusProhibit timer initial value. */ -} rlc_am_info_t; - -//----------------------------------------------------------------------------- -/*! \fn void rlc_am_init (const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP) -* \brief Initialize the RLC AM protocol instance, reset variables, allocate buffers, lists, then, the next step in order have a running RLC AM instance is to configure and set debug informations for this RLC instance. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void rlc_am_init (const protocol_ctxt_t* const ctxtP, rlc_am_entity_t* rlc_pP); - -/*! \fn void rlc_am_cleanup(rlc_am_entity_t *const rlc_pP) -* \brief Free all memory resources allocated and kept by this RLC AM instance. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void rlc_am_cleanup(rlc_am_entity_t* rlc_pP); - -/*! \fn void rlc_am_configure(const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP, uint16_t max_retx_thresholdP, uint16_t poll_pduP, uint16_t poll_byteP, uint32_t t_poll_retransmitP, uint32_t t_reorderingP, uint32_t t_status_prohibitP) -* \brief Set RLC AM protocol parameters. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] max_retx_thresholdP Limit the number of retransmissions of an -AMD PDU. -* \param[in] poll_pduP Trigger a poll for every poll_pduP PDUs. -* \param[in] poll_byteP Trigger a poll for every pollByte bytes. -* \param[in] t_poll_retransmitP This timer is used by the transmitting side of an AM RLC entity in order to retransmit a poll, value in frames. -* \param[in] t_reorderingP This timer is used by the receiving side of an AM RLC entity in order to detect loss of RLC PDUs at lower layer, value in frames. -* \param[in] t_status_prohibitP This timer is used by the receiving side of an AM RLC entity in order to prohibit transmission of a STATUS PDU, value in frames. -*/ -void rlc_am_configure(const protocol_ctxt_t* const ctxtP, - rlc_am_entity_t * const rlc_pP, - const uint16_t max_retx_thresholdP, - const uint16_t poll_pduP, - const uint16_t poll_byteP, - const uint32_t t_poll_retransmitP, - const uint32_t t_reorderingP, - const uint32_t t_status_prohibitP); - - -/*! \fn void rlc_am_set_debug_infos(const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP, const srb_flag_t srb_flagP, const rb_id_t rb_idP) -* \brief Set informations that will be displayed in traces, helping the debug process. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). -* \param[in] rb_idP Radio bearer identifier. -* \param[in] chan_idP Transport channel identifier. -*/ -void rlc_am_set_debug_infos(const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP, const srb_flag_t srb_flagP, const rb_id_t rb_idP, const logical_chan_id_t chan_idP); -/** @} */ -#endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c deleted file mode 100644 index a5f0b4f9ef096ecd1b1a8e78da076dc3141d23d3..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_REASSEMBLY_C 1 -#include "platform_types.h" -//----------------------------------------------------------------------------- - -#include "assertions.h" -#include "rlc.h" -#include "rlc_am.h" -#include "list.h" -//#include "LAYER2/MAC/extern.h" -#include "common/utils/LOG/log.h" - -//----------------------------------------------------------------------------- -inline void -rlc_am_clear_rx_sdu ( - const protocol_ctxt_t *const ctxt_pP, - rlc_am_entity_t *const rlc_pP) { - rlc_pP->output_sdu_size_to_write = 0; -} -//----------------------------------------------------------------------------- -void -rlc_am_reassembly ( - const protocol_ctxt_t *const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - uint8_t *src_pP, - const int32_t lengthP) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PAYLOAD] reassembly() %d bytes\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - lengthP); - - if (rlc_pP->output_sdu_in_construction == NULL) { - rlc_pP->output_sdu_in_construction = get_free_mem_block (RLC_SDU_MAX_SIZE, __func__); - rlc_pP->output_sdu_size_to_write = 0; - - //assert(rlc_pP->output_sdu_in_construction != NULL); - if(rlc_pP->output_sdu_in_construction == NULL) { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PAYLOAD] output_sdu_in_construction is NULL\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - return; - } - } - - if (rlc_pP->output_sdu_in_construction != NULL) { - // check if no overflow in size - if ((rlc_pP->output_sdu_size_to_write + lengthP) <= RLC_SDU_MAX_SIZE) { - memcpy (&rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write], src_pP, lengthP); - rlc_pP->output_sdu_size_to_write += lengthP; - } else { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PAYLOAD] ERROR SDU SIZE OVERFLOW SDU GARBAGED\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); -#if STOP_ON_IP_TRAFFIC_OVERLOAD - AssertFatal(0, PROTOCOL_RLC_AM_CTXT_FMT" RLC_AM_DATA_IND, SDU SIZE OVERFLOW SDU GARBAGED\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); -#endif - // erase SDU - rlc_pP->output_sdu_size_to_write = 0; - } - } else { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PAYLOAD] ERROR OUTPUT SDU IS NULL\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); -#if STOP_ON_IP_TRAFFIC_OVERLOAD - AssertFatal(0, PROTOCOL_RLC_AM_CTXT_FMT" RLC_AM_DATA_IND, SDU DROPPED, OUT OF MEMORY\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); -#endif - } -} -//----------------------------------------------------------------------------- -void -rlc_am_send_sdu ( - const protocol_ctxt_t *const ctxt_pP, - rlc_am_entity_t *const rlc_pP) { - if ((rlc_pP->output_sdu_in_construction)) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND_SDU] %d bytes sdu %p\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->output_sdu_size_to_write, - rlc_pP->output_sdu_in_construction); - - if (rlc_pP->output_sdu_size_to_write > 0) { - rlc_pP->stat_rx_pdcp_sdu += 1; - rlc_pP->stat_rx_pdcp_bytes += rlc_pP->output_sdu_size_to_write; -#if TEST_RLC_AM - rlc_am_v9_3_0_test_data_ind (rlc_pP->module_id, - rlc_pP->rb_id, - rlc_pP->output_sdu_size_to_write, - rlc_pP->output_sdu_in_construction); -#else - - if ( LOG_DEBUGFLAG(DEBUG_RLC)) { - char message_string[7000]; - size_t message_string_size = 0; - int octet_index, index; - message_string_size += sprintf(&message_string[message_string_size], "Bearer : %ld\n", rlc_pP->rb_id); - message_string_size += sprintf(&message_string[message_string_size], "SDU size : %u\n", rlc_pP->output_sdu_size_to_write); - message_string_size += sprintf(&message_string[message_string_size], "\nPayload : \n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - message_string_size += sprintf(&message_string[message_string_size], " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - - for (octet_index = 0; octet_index < rlc_pP->output_sdu_size_to_write; octet_index++) { - if ((octet_index % 16) == 0) { - if (octet_index != 0) { - message_string_size += sprintf(&message_string[message_string_size], " |\n"); - } - - message_string_size += sprintf(&message_string[message_string_size], " %04d |", octet_index); - } - - /* - * Print every single octet in hexadecimal form - */ - message_string_size += sprintf(&message_string[message_string_size], - " %02x", - rlc_pP->output_sdu_in_construction->data[octet_index]); - /* - * Align newline and pipes according to the octets in groups of 2 - */ - } - - /* - * Append enough spaces and put final pipe - */ - for (index = octet_index; index < 16; ++index) { - message_string_size += sprintf(&message_string[message_string_size], " "); - } - - message_string_size += sprintf(&message_string[message_string_size], " |\n"); - LOG_T(RLC, "%s", message_string); - } - -#if !ENABLE_ITTI - RLC_AM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); -#endif - rlc_data_ind (ctxt_pP, - BOOL_NOT(rlc_pP->is_data_plane), - MBMS_FLAG_NO, - rlc_pP->rb_id, - rlc_pP->output_sdu_size_to_write, - rlc_pP->output_sdu_in_construction); -#if !ENABLE_ITTI - RLC_AM_MUTEX_LOCK(&rlc_pP->lock_input_sdus, ctxt_pP, rlc_pP); -#endif -#endif - rlc_pP->output_sdu_in_construction = NULL; - } else { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND_SDU] ERROR SIZE <= 0 ... DO NOTHING, SET SDU SIZE TO 0\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - //msg("[RLC_AM][MOD %d] Freeing mem_block ...\n", rlc_pP->module_id); - //free_mem_block (rlc_pP->output_sdu_in_construction, __func__); - //Assertion(eNB)_PRAN_DesignDocument_annex No.764 - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" SEND SDU REQUESTED %d bytes\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->output_sdu_size_to_write); - /* - AssertFatal(3==4, - PROTOCOL_RLC_AM_CTXT_FMT" SEND SDU REQUESTED %d bytes", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->output_sdu_size_to_write); - */ - } - - rlc_pP->output_sdu_size_to_write = 0; - } -} -//----------------------------------------------------------------------------- -void rlc_am_reassemble_pdu(const protocol_ctxt_t *const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - mem_block_t *const tb_pP, - bool free_rlc_pdu) { - int i,j; - rlc_am_pdu_info_t *pdu_info = &((rlc_am_rx_pdu_management_t *)(tb_pP->data))->pdu_info; - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU SN=%03d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_info->sn); - - if ( LOG_DEBUGFLAG(DEBUG_RLC)) { - rlc_am_display_data_pdu_infos(ctxt_pP, rlc_pP, pdu_info); - } - - if (pdu_info->e == RLC_E_FIXED_PART_DATA_FIELD_FOLLOW) { - switch (pdu_info->fi) { - case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=11 (00)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - // one complete SDU - rlc_am_send_sdu(ctxt_pP, rlc_pP); // may be not necessary - rlc_am_reassembly (ctxt_pP, rlc_pP, pdu_info->payload, pdu_info->payload_size); - rlc_am_send_sdu(ctxt_pP, rlc_pP); // may be not necessary - //rlc_pP->reassembly_missing_sn_detected = 0; - break; - - case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=10 (01)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - // one beginning segment of SDU in PDU - rlc_am_send_sdu(ctxt_pP, rlc_pP); // may be not necessary - rlc_am_reassembly (ctxt_pP, rlc_pP,pdu_info->payload, pdu_info->payload_size); - //rlc_pP->reassembly_missing_sn_detected = 0; - break; - - case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=01 (10)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - // one last segment of SDU - //if (rlc_pP->reassembly_missing_sn_detected == 0) { - rlc_am_reassembly (ctxt_pP, rlc_pP, pdu_info->payload, pdu_info->payload_size); - rlc_am_send_sdu(ctxt_pP, rlc_pP); - //} // else { clear sdu already done - //rlc_pP->reassembly_missing_sn_detected = 0; - break; - - case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=00 (11)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - //if (rlc_pP->reassembly_missing_sn_detected == 0) { - // one whole segment of SDU in PDU - rlc_am_reassembly (ctxt_pP, rlc_pP, pdu_info->payload, pdu_info->payload_size); - //} else { - // rlc_pP->reassembly_missing_sn_detected = 1; // not necessary but for readability of the code - //} - break; - - default: - //Assertion(eNB)_PRAN_DesignDocument_annex No.1428 - LOG_E(RLC, "RLC_E_FIXED_PART_DATA_FIELD_FOLLOW error pdu_info->fi[%d]\n", pdu_info->fi); - // assert(0 != 0); - } - } else { - switch (pdu_info->fi) { - case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU FI=11 (00) Li=", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - - for (i=0; i < pdu_info->num_li; i++) { - LOG_D(RLC, "%d ",pdu_info->li_list[i]); - } - - LOG_D(RLC, "\n"); - //msg(" remaining size %d\n",size); - // N complete SDUs - rlc_am_send_sdu(ctxt_pP, rlc_pP); - j = 0; - - for (i = 0; i < pdu_info->num_li; i++) { - rlc_am_reassembly (ctxt_pP, rlc_pP, &pdu_info->payload[j], pdu_info->li_list[i]); - rlc_am_send_sdu(ctxt_pP, rlc_pP); - j = j + pdu_info->li_list[i]; - } - - if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug - // data is already ok, done by last loop above - rlc_am_reassembly (ctxt_pP, rlc_pP, &pdu_info->payload[j], pdu_info->hidden_size); - rlc_am_send_sdu(ctxt_pP, rlc_pP); - } - - //rlc_pP->reassembly_missing_sn_detected = 0; - break; - - case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU FI=10 (01) Li=", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - - for (i=0; i < pdu_info->num_li; i++) { - LOG_D(RLC, "%d ",pdu_info->li_list[i]); - } - - LOG_D(RLC, "\n"); - //msg(" remaining size %d\n",size); - // N complete SDUs + one segment of SDU in PDU - rlc_am_send_sdu(ctxt_pP, rlc_pP); - j = 0; - - for (i = 0; i < pdu_info->num_li; i++) { - rlc_am_reassembly (ctxt_pP, rlc_pP, &pdu_info->payload[j], pdu_info->li_list[i]); - rlc_am_send_sdu(ctxt_pP, rlc_pP); - j = j + pdu_info->li_list[i]; - } - - if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug - // data is already ok, done by last loop above - rlc_am_reassembly (ctxt_pP, rlc_pP, &pdu_info->payload[j], pdu_info->hidden_size); - } - - //rlc_pP->reassembly_missing_sn_detected = 0; - break; - - case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU FI=01 (10) Li=", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - - for (i=0; i < pdu_info->num_li; i++) { - LOG_D(RLC, "%d ",pdu_info->li_list[i]); - } - - LOG_D(RLC, "\n"); - //msg(" remaining size %d\n",size); - // one last segment of SDU + N complete SDUs in PDU - j = 0; - - for (i = 0; i < pdu_info->num_li; i++) { - rlc_am_reassembly (ctxt_pP, rlc_pP, &pdu_info->payload[j], pdu_info->li_list[i]); - rlc_am_send_sdu(ctxt_pP, rlc_pP); - j = j + pdu_info->li_list[i]; - } - - if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug - // data is already ok, done by last loop above - rlc_am_reassembly (ctxt_pP, rlc_pP, &pdu_info->payload[j], pdu_info->hidden_size); - rlc_am_send_sdu(ctxt_pP, rlc_pP); - } - - //rlc_pP->reassembly_missing_sn_detected = 0; - break; - - case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PDU] TRY REASSEMBLY PDU FI=00 (11) Li=", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - - for (i=0; i < pdu_info->num_li; i++) { - LOG_D(RLC, "%d ",pdu_info->li_list[i]); - } - - LOG_D(RLC, "\n"); - //msg(" remaining size %d\n",size); - j = 0; - - for (i = 0; i < pdu_info->num_li; i++) { - rlc_am_reassembly (ctxt_pP, rlc_pP, &pdu_info->payload[j], pdu_info->li_list[i]); - rlc_am_send_sdu(ctxt_pP, rlc_pP); - j = j + pdu_info->li_list[i]; - } - - if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug - // data is already ok, done by last loop above - rlc_am_reassembly (ctxt_pP, rlc_pP, &pdu_info->payload[j], pdu_info->hidden_size); - } - - //rlc_pP->reassembly_missing_sn_detected = 0; - break; - - default: - //Assertion(eNB)_PRAN_DesignDocument_annex No.1429 - LOG_E(RLC, "not RLC_E_FIXED_PART_DATA_FIELD_FOLLOW error pdu_info->fi[%d]\n", pdu_info->fi); - // assert(1 != 1); - } - } - - if (free_rlc_pdu) { - free_mem_block(tb_pP, __func__); - } -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.h deleted file mode 100644 index 839e7d9304fbce3cb2371017018b19f9921e97c7..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_reassembly.h -* \brief This file defines the prototypes of the functions dealing with the reassembly of segments. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_internal_reassembly_impl_ RLC AM Reassembly Internal Reference Implementation -* @ingroup _rlc_am_internal_impl_ -* @{ -*/ -#ifndef __RLC_AM_REASSEMBLY_H__ -# define __RLC_AM_REASSEMBLY_H__ -/*! \fn void rlc_am_clear_rx_sdu (const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP) -* \brief Reset the data cursor index in the output SDU buffer to zero. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void rlc_am_clear_rx_sdu (const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP); - -/*! \fn void rlc_am_reassembly (const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pPuint8_t * srcP, int32_t lengthP) -* \brief Concatenate datas at the tail of the output SDU in construction. This SDU in construction will be sent to higher layer. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] srcP Pointer on data to be reassemblied. -* \param[in] lengthP Length of data to be reassemblied. -*/ -void rlc_am_reassembly (const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP, uint8_t * srcP, int32_t lengthP); - -/*! \fn void rlc_am_send_sdu (rlc_am_entity_t *rlc_pP,frame_t frameP) -* \brief Send the output SDU in construction to higher layer. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void rlc_am_send_sdu (const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP); - -/*! \fn void rlc_am_reassemble_pdu(const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP, const mem_block_t* const tb_pP, bool free_rlc_pdu) -* \brief Reassembly a RLC AM PDU, depending of the content of this PDU, data will be reassemblied to the current output SDU, the current will be sent to higher layers or not, after or before the reassembly, or no send of SDU will be triggered, depending on FI field in PDU header. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] tb_pP RLC AM PDU embedded in a mem_block_t. -* \param[in] free_rlc_pdu Flag for freeing RLC AM PDU after reassembly. -*/ -void rlc_am_reassemble_pdu(const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP, mem_block_t* const tb_pP, bool free_rlc_pdu); -/** @} */ -#endif - diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c deleted file mode 100644 index a749aa035e1e161e2cc76b998a126b225cec9289..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c +++ /dev/null @@ -1,533 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_RECEIVER_C 1 -#include "platform_types.h" -//----------------------------------------------------------------------------- -#include "assertions.h" -#include "rlc.h" -#include "rlc_am.h" -#include "list.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" - - -//----------------------------------------------------------------------------- -signed int -rlc_am_get_data_pdu_infos( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - rlc_am_pdu_sn_10_t* header_pP, - int16_t total_sizeP, - rlc_am_pdu_info_t* pdu_info_pP) -{ - memset(pdu_info_pP, 0, sizeof (rlc_am_pdu_info_t)); - - int16_t sum_li = 0; - pdu_info_pP->d_c = header_pP->b1 >> 7; - pdu_info_pP->num_li = 0; - -//Assertion(eNB)_PRAN_DesignDocument_annex No.766 - if(pdu_info_pP->d_c == 0) - { - LOG_E(RLC, "RLC AM Rx PDU Data D/C Header Error LcId=%d\n", rlc_pP->channel_id); - return -2; - } -/* - AssertFatal (pdu_info_pP->d_c != 0, "RLC AM Rx PDU Data D/C Header Error LcId=%d\n", rlc_pP->channel_id); -*/ - pdu_info_pP->rf = (header_pP->b1 >> 6) & 0x01; - pdu_info_pP->p = (header_pP->b1 >> 5) & 0x01; - pdu_info_pP->fi = (header_pP->b1 >> 3) & 0x03; - pdu_info_pP->e = (header_pP->b1 >> 2) & 0x01; - pdu_info_pP->sn = header_pP->b2 + (((uint16_t)(header_pP->b1 & 0x03)) << 8); - - pdu_info_pP->header_size = 2; - - if (pdu_info_pP->rf) { - pdu_info_pP->lsf = (header_pP->data[0] >> 7) & 0x01; - pdu_info_pP->so = header_pP->data[1] + (((uint16_t)(header_pP->data[0] & 0x7F)) << 8); - pdu_info_pP->payload = &header_pP->data[2]; - pdu_info_pP->header_size += 2; - } else { - pdu_info_pP->payload = &header_pP->data[0]; - } - - if (pdu_info_pP->e) { - rlc_am_e_li_t *e_li; - unsigned int li_length_in_bytes = 1; - unsigned int li_to_read = 1; - - if (pdu_info_pP->rf) { - e_li = (rlc_am_e_li_t*)(&header_pP->data[2]); - } else { - e_li = (rlc_am_e_li_t*)(header_pP->data); - } - - while (li_to_read) { - li_length_in_bytes = li_length_in_bytes ^ 3; - - if (li_length_in_bytes == 2) { - pdu_info_pP->li_list[pdu_info_pP->num_li] = ((uint16_t)(e_li->b1 << 4)) & 0x07F0; - pdu_info_pP->li_list[pdu_info_pP->num_li] |= (((uint8_t)(e_li->b2 >> 4)) & 0x000F); - li_to_read = e_li->b1 & 0x80; - pdu_info_pP->header_size += 2; - } else { - pdu_info_pP->li_list[pdu_info_pP->num_li] = ((uint16_t)(e_li->b2 << 8)) & 0x0700; - pdu_info_pP->li_list[pdu_info_pP->num_li] |= e_li->b3; - li_to_read = e_li->b2 & 0x08; - e_li++; - pdu_info_pP->header_size += 1; - } - - sum_li += pdu_info_pP->li_list[pdu_info_pP->num_li]; - pdu_info_pP->num_li = pdu_info_pP->num_li + 1; - - if (pdu_info_pP->num_li > RLC_AM_MAX_SDU_IN_PDU) { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[GET PDU INFO] SN %04d TOO MANY LIs ", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_info_pP->sn); - return -2; - } - } - - if (li_length_in_bytes == 2) { - pdu_info_pP->payload = &e_li->b3; - } else { - pdu_info_pP->payload = &e_li->b1; - } - } - - pdu_info_pP->payload_size = total_sizeP - pdu_info_pP->header_size; - - if (pdu_info_pP->payload_size > sum_li) { - pdu_info_pP->hidden_size = pdu_info_pP->payload_size - sum_li; - } - - return 0; -} -//----------------------------------------------------------------------------- -void -rlc_am_display_data_pdu_infos( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP, - rlc_am_pdu_info_t* pdu_info_pP) -{ - int num_li; - - if (pdu_info_pP->d_c) { - if (pdu_info_pP->rf) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[DISPLAY DATA PDU] RX DATA PDU SN %04d FI %1d SO %05d LSF %01d POLL %1d ", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_info_pP->sn, - pdu_info_pP->fi, - pdu_info_pP->so, - pdu_info_pP->lsf, pdu_info_pP->p); - } else { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[DISPLAY DATA PDU] RX DATA PDU SN %04d FI %1d POLL %1d ", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_info_pP->sn, - pdu_info_pP->fi, - pdu_info_pP->p); - } - - for (num_li = 0; num_li < pdu_info_pP->num_li; num_li++) { - LOG_D(RLC, "LI %05d ", pdu_info_pP->li_list[num_li]); - } - - if (pdu_info_pP->hidden_size > 0) { - LOG_D(RLC, "hidden size %05d ", pdu_info_pP->hidden_size); - } - - LOG_D(RLC, "\n"); - } else { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[DISPLAY DATA PDU] ERROR RX CONTROL PDU\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - } -} -// assumed the sn of the tb_p is equal to VR(MS) -//----------------------------------------------------------------------------- -void -rlc_am_rx_update_vr_ms( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP, - mem_block_t* tb_pP) -{ - //rlc_am_pdu_info_t* pdu_info_p = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; - rlc_am_pdu_info_t* pdu_info_cursor_p = NULL; - mem_block_t* cursor_p; - - cursor_p = tb_pP; - - if (cursor_p) { - do { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - - if ((((rlc_am_rx_pdu_management_t*)(cursor_p->data))->all_segments_received == 0) || - (rlc_pP->vr_ms != pdu_info_cursor_p->sn)) { - -#if TRACE_RLC_AM_RX - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[UPDATE VR(MS)] UPDATED VR(MS) %04d -> %04d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->vr_ms, pdu_info_cursor_p->sn); -#endif - - return; - } - - rlc_pP->vr_ms = RLC_AM_NEXT_SN(pdu_info_cursor_p->sn); - cursor_p = cursor_p->next; - } while ((cursor_p != NULL) && (rlc_pP->vr_ms != rlc_pP->vr_h)); - - } -} -// assumed the sn of the tb_p is equal to VR(R) -//----------------------------------------------------------------------------- -void -rlc_am_rx_update_vr_r( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP, - mem_block_t* tb_pP) -{ - rlc_am_pdu_info_t* pdu_info_cursor_p = NULL; - mem_block_t* cursor_p; - - cursor_p = tb_pP; - - if (cursor_p) { - do { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - - if ((((rlc_am_rx_pdu_management_t*)(cursor_p->data))->all_segments_received == 0) || - (rlc_pP->vr_r != pdu_info_cursor_p->sn)) { - return; - } - -#if TRACE_RLC_AM_RX - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[UPDATE VR(R)] UPDATED VR(R) %04d -> %04d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->vr_r, - (pdu_info_cursor_p->sn + 1) & RLC_AM_SN_MASK); -#endif - - if (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.rf == 1) { - if (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.lsf == 1) { - rlc_pP->vr_r = (rlc_pP->vr_r + 1) & RLC_AM_SN_MASK; - } - } else { - rlc_pP->vr_r = (rlc_pP->vr_r + 1) & RLC_AM_SN_MASK; - } - - cursor_p = cursor_p->next; - } while (cursor_p != NULL); - - //rlc_pP->vr_r = (pdu_info_cursor_p->sn + 1) & RLC_AM_SN_MASK; - } -} -//----------------------------------------------------------------------------- -void -rlc_am_receive_routing ( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP, - struct mac_data_ind data_indP) -{ - mem_block_t *tb_p = NULL; - uint8_t *first_byte_p = NULL; - sdu_size_t tb_size_in_bytes; - RLC_AM_MUTEX_LOCK(&rlc_pP->lock_input_sdus, ctxt_pP, rlc_pP); - - while ((tb_p = list_remove_head (&data_indP.data))) { - first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr; - tb_size_in_bytes = ((struct mac_tb_ind *) (tb_p->data))->size; - - if (tb_size_in_bytes > 0) { - if ((*first_byte_p & 0x80) == 0x80) { - rlc_pP->stat_rx_data_bytes += tb_size_in_bytes; - rlc_pP->stat_rx_data_pdu += 1; - rlc_am_receive_process_data_pdu (ctxt_pP, rlc_pP, tb_p, first_byte_p, tb_size_in_bytes); - } else { - rlc_pP->stat_rx_control_bytes += tb_size_in_bytes; - rlc_pP->stat_rx_control_pdu += 1; - rlc_am_receive_process_control_pdu (ctxt_pP, rlc_pP, tb_p, &first_byte_p, &tb_size_in_bytes); - // Test if remaining bytes not processed (up to know, highest probability is bug in MAC) -//Assertion(eNB)_PRAN_DesignDocument_annex No.767 - if(tb_size_in_bytes != 0) - { - LOG_E(RLC, "Remaining %d bytes following a control PDU\n", - tb_size_in_bytes); - } -/* - AssertFatal( tb_size_in_bytes == 0, - "Remaining %d bytes following a control PDU", - tb_size_in_bytes); -*/ - } - - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RX ROUTING] VR(R)=%03d VR(MR)=%03d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->vr_r, - rlc_pP->vr_mr); - } - } // end while - RLC_AM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); -} -//----------------------------------------------------------------------------- -void -rlc_am_receive_process_data_pdu ( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP, - mem_block_t* tb_pP, - uint8_t* first_byte_pP, - uint16_t tb_size_in_bytesP) -{ - // 5.1.3.2 Receive operations - // 5.1.3.2.1 General - // The receiving side of an AM RLC entity shall maintain a receiving window according to state variables VR(R) and - // VR(MR) as follows: - // - a SN falls within the receiving window if VR(R) <= SN < VR(MR); - // - a SN falls outside of the receiving window otherwise. - // - // When receiving a RLC data PDU from lower layer, the receiving side of an AM RLC entity shall: - // - either discard the received RLC data PDU or place it in the reception buffer (see sub clause 5.1.3.2.2); - // - if the received RLC data PDU was placed in the reception buffer: - // - update state variables, reassemble and deliver RLC SDUs to upper layer and start/stop t-Reordering as - // needed (see sub clause 5.1.3.2.3). - // When t-Reordering expires, the receiving side of an AM RLC entity shall: - // - update state variables and start t-Reordering as needed (see sub clause 5.1.3.2.4). - - - // 5.1.3.2.2 Actions when a RLC data PDU is received from lower layer - // When a RLC data PDU is received from lower layer, where the RLC data PDU contains byte segment numbers y to z of - // an AMD PDU with SN = x, the receiving side of an AM RLC entity shall: - // - if x falls outside of the receiving window; or - // - if byte segment numbers y to z of the AMD PDU with SN = x have been received before: - // - discard the received RLC data PDU; - // - else: - // - place the received RLC data PDU in the reception buffer; - // - if some byte segments of the AMD PDU contained in the RLC data PDU have been received before: - // - discard the duplicate byte segments. - rlc_am_pdu_info_t* pdu_info_p = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; - rlc_am_pdu_sn_10_t* rlc_am_pdu_sn_10_p = (rlc_am_pdu_sn_10_t*)first_byte_pP; - rlc_am_rx_pdu_status_t pdu_status = RLC_AM_DATA_PDU_STATUS_OK; - bool reassemble = false; - - if (rlc_am_get_data_pdu_infos(ctxt_pP,rlc_pP, rlc_am_pdu_sn_10_p, tb_size_in_bytesP, pdu_info_p) >= 0) { - - ((rlc_am_rx_pdu_management_t*)(tb_pP->data))->all_segments_received = 0; - - if (RLC_AM_SN_IN_WINDOW(pdu_info_p->sn, rlc_pP->vr_r)) { - - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SN=%04d] VR(R) %04d VR(H) %04d VR(MR) %04d VR(MS) %04d VR(X) %04d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_info_p->sn, - rlc_pP->vr_r, - rlc_pP->vr_h, - rlc_pP->vr_mr, - rlc_pP->vr_ms, - rlc_pP->vr_x); - - pdu_status = rlc_am_rx_list_check_duplicate_insert_pdu(ctxt_pP, rlc_pP,tb_pP); - if (pdu_status != RLC_AM_DATA_PDU_STATUS_OK) { - rlc_pP->stat_rx_data_pdu_dropped += 1; - rlc_pP->stat_rx_data_bytes_dropped += tb_size_in_bytesP; - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] PDU DISCARDED CAUSE=%d SN=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_status,pdu_info_p->sn); -#if RLC_STOP_ON_LOST_PDU - AssertFatal( 0 == 1, - PROTOCOL_RLC_AM_CTXT_FMT" LOST PDU DETECTED\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); -#endif - } else { - // 5.1.3.2.3 - // Actions when a RLC data PDU is placed in the reception buffer - // - // When a RLC data PDU with SN = x is placed in the reception buffer, the receiving side of an AM RLC entity shall: - // - if x >= VR(H) - // - update VR(H) to x+ 1; - // - // - if all byte segments of the AMD PDU with SN = VR(MS) are received: - // - update VR(MS) to the SN of the first AMD PDU with SN > current VR(MS) for which not all byte segments - // have been received; - // - // - if x = VR(R): - // - if all byte segments of the AMD PDU with SN = VR(R) are received: - // - update VR(R) to the SN of the first AMD PDU with SN > current VR(R) for which not all byte segments - // have been received; - // - update VR(MR) to the updated VR(R) + AM_Window_Size; - // - // - reassemble RLC SDUs from any byte segments of AMD PDUs with SN that falls outside of the receiving - // window and in-sequence byte segments of the AMD PDU with SN = VR(R), remove RLC headers when - // doing so and deliver the reassembled RLC SDUs to upper layer in sequence if not delivered before; - // - // - if t-Reordering is running: - // - if VR(X) = VR(R); or - // - if VR(X) falls outside of the receiving window and VR(X) is not equal to VR(MR): - // - stop and reset t-Reordering; - // - // - if t-Reordering is not running (includes the case t-Reordering is stopped due to actions above): - // - if VR (H) > VR(R): - // - start t-Reordering; - // - set VR(X) to VR(H). - - -#if TRACE_RLC_AM_RX - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] RX LIST AFTER INSERTION:\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - rlc_am_rx_list_display(rlc_pP, "rlc_am_receive_process_data_pdu AFTER INSERTION "); -#endif - - /* 1) Update vrH if sn >= vrH */ - if (RLC_AM_DIFF_SN(pdu_info_p->sn,rlc_pP->vr_r) >= RLC_AM_DIFF_SN(rlc_pP->vr_h,rlc_pP->vr_r)) - { - rlc_pP->vr_h = RLC_AM_NEXT_SN(pdu_info_p->sn); - } - - rlc_am_rx_check_all_byte_segments(ctxt_pP, rlc_pP, tb_pP); - - /* 2) Reordering Window Processing: Update vr_ms if sn = vr_ms and all bytes received for sn */ - if ((pdu_info_p->sn == rlc_pP->vr_ms) && (((rlc_am_rx_pdu_management_t*)(tb_pP->data))->all_segments_received)) { - rlc_am_rx_update_vr_ms(ctxt_pP, rlc_pP, tb_pP); - } - - if (pdu_info_p->sn == rlc_pP->vr_r) { -mem_block_t* cursor_p = rlc_pP->receiver_buffer.head; -rlc_am_rx_pdu_management_t * pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); -if( (((rlc_am_rx_pdu_management_t*)(tb_pP->data))->all_segments_received) == (pdu_cursor_mgnt_p->all_segments_received)){ - if (((rlc_am_rx_pdu_management_t*)(tb_pP->data))->all_segments_received) { - rlc_am_rx_update_vr_r(ctxt_pP, rlc_pP, tb_pP); - rlc_pP->vr_mr = (rlc_pP->vr_r + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; - } - reassemble = rlc_am_rx_check_vr_reassemble(ctxt_pP, rlc_pP); - //TODO : optimization : check whether a reassembly is needed by looking at LI, FI, SO, etc... -}else{ - LOG_E(RLC, "BAD all_segments_received!!! discard buffer!!!\n"); - /* Discard received block if out of window, duplicate or header error */ - free_mem_block (tb_pP, __func__); -} - } - - //FNA: fix check VrX out of receiving window - if ((rlc_pP->t_reordering.running) || ((rlc_pP->t_reordering.ms_duration == 0) && (rlc_pP->vr_x != RLC_SN_UNDEFINED))) { - if ((rlc_pP->vr_x == rlc_pP->vr_r) || (!(RLC_AM_SN_IN_WINDOW(rlc_pP->vr_x, rlc_pP->vr_r)) && (rlc_pP->vr_x != rlc_pP->vr_mr))) { - rlc_am_stop_and_reset_timer_reordering(ctxt_pP, rlc_pP); - rlc_pP->vr_x = RLC_SN_UNDEFINED; - } - } - - if (!(rlc_pP->t_reordering.running)) { - if (rlc_pP->vr_h != rlc_pP->vr_r) { // - if VR (H) > VR(R) translated to - if VR (H) != VR(R) - rlc_pP->vr_x = rlc_pP->vr_h; - if (rlc_pP->t_reordering.ms_duration != 0) { - rlc_am_start_timer_reordering(ctxt_pP, rlc_pP); - } - else { - /* specific case for no timer reordering configured */ - /* reordering window directly advances with vrH */ - rlc_pP->vr_ms = rlc_pP->vr_h; - - /* Trigger a Status and clear any existing Delay Flag */ - RLC_AM_SET_STATUS(rlc_pP->status_requested,RLC_AM_STATUS_TRIGGERED_T_REORDERING); - RLC_AM_CLEAR_STATUS(rlc_pP->status_requested,RLC_AM_STATUS_TRIGGERED_DELAYED); - rlc_pP->sn_status_triggered_delayed = RLC_SN_UNDEFINED; - } - } - } - } - - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SN=%04d] NEW VR(R) %04d VR(H) %04d VR(MS) %04d VR(MR) %04d VR(X) %04d reassemble=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_info_p->sn, - rlc_pP->vr_r, - rlc_pP->vr_h, - rlc_pP->vr_ms, - rlc_pP->vr_mr, - rlc_pP->vr_x, - reassemble); - } else { - rlc_pP->stat_rx_data_pdu_out_of_window += 1; - rlc_pP->stat_rx_data_bytes_out_of_window += tb_size_in_bytesP; - pdu_status = RLC_AM_DATA_PDU_STATUS_SN_OUTSIDE_WINDOW; - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] PDU OUT OF RX WINDOW, DISCARDED, SN=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_info_p->sn); - } - - /* 3) Check for triggering a Tx Status PDU if a poll is received or if a pending status was delayed */ - if ((pdu_info_p->p) && (pdu_status < RLC_AM_DATA_PDU_STATUS_BUFFER_FULL)) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] POLL BIT SET, STATUS REQUESTED:\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - - /* Polling Info Saving for In and Out of Window PDU */ - /* avoid multi status trigger */ - if ((RLC_AM_GET_STATUS(rlc_pP->status_requested,RLC_AM_STATUS_TRIGGERED_DELAYED)) || - !(RLC_AM_GET_STATUS(rlc_pP->status_requested,(RLC_AM_STATUS_TRIGGERED_POLL | RLC_AM_STATUS_TRIGGERED_T_REORDERING)))) - { - RLC_AM_SET_STATUS(rlc_pP->status_requested,RLC_AM_STATUS_TRIGGERED_POLL); - - if ((pdu_status != RLC_AM_DATA_PDU_STATUS_OK) || ((pdu_status == RLC_AM_DATA_PDU_STATUS_OK) && - (!(RLC_AM_SN_IN_WINDOW(pdu_info_p->sn,rlc_pP->vr_r)) || - (RLC_AM_DIFF_SN(pdu_info_p->sn,rlc_pP->vr_r) < RLC_AM_DIFF_SN(rlc_pP->vr_ms,rlc_pP->vr_r))) - ) - ) - { - /* Conditions are met for sending a Status Report */ - /* Then clear Delay Flag and reset its corresponding sn */ - RLC_AM_CLEAR_STATUS(rlc_pP->status_requested,RLC_AM_STATUS_TRIGGERED_DELAYED); - rlc_pP->sn_status_triggered_delayed = RLC_SN_UNDEFINED; - } - else if (rlc_pP->sn_status_triggered_delayed == RLC_SN_UNDEFINED) - { - /* Delay status trigger if pdustatus OK and sn>= vr_ms */ - /* Note: vr_r and vr_ms have been updated */ - RLC_AM_SET_STATUS(rlc_pP->status_requested,RLC_AM_STATUS_TRIGGERED_DELAYED); - rlc_pP->sn_status_triggered_delayed = pdu_info_p->sn; - } - } - } - - /* ReEnable a previously delayed Status Trigger if PDU discarded or */ - /* sn no more in RxWindow due to RxWindow advance or sn < vr_ms */ - if ((RLC_AM_GET_STATUS(rlc_pP->status_requested,RLC_AM_STATUS_TRIGGERED_DELAYED)) && - (pdu_status == RLC_AM_DATA_PDU_STATUS_OK) && - (!(RLC_AM_SN_IN_WINDOW(rlc_pP->sn_status_triggered_delayed,rlc_pP->vr_r)) || - (RLC_AM_DIFF_SN(rlc_pP->sn_status_triggered_delayed,rlc_pP->vr_r) < RLC_AM_DIFF_SN(rlc_pP->vr_ms,rlc_pP->vr_r))) - ) - { - RLC_AM_CLEAR_STATUS(rlc_pP->status_requested,RLC_AM_STATUS_TRIGGERED_DELAYED); - rlc_pP->sn_status_triggered_delayed = RLC_SN_UNDEFINED; - } - - - } else { - pdu_status = RLC_AM_DATA_PDU_STATUS_HEADER_ERROR; - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] PDU DISCARDED BAD HEADER FORMAT SN=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_info_p->sn); - } - - if (pdu_status != RLC_AM_DATA_PDU_STATUS_OK) { - /* Discard received block if out of window, duplicate or header error */ - free_mem_block (tb_pP, __func__); - } - else if (reassemble) { - /* Reassemble SDUs */ - rlc_am_rx_list_reassemble_rlc_sdus(ctxt_pP, rlc_pP); - } -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.h deleted file mode 100644 index fdbd95873d3a6ee3c8c5a3a0253903aa79fd9a2d..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_receiver.h -* \brief This file defines the prototypes of the functions dealing with the first stage of the receiving process. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_internal_receiver_impl_ RLC AM Receiver Internal Reference Implementation -* @ingroup _rlc_am_internal_impl_ -* @{ -*/ -# ifndef __RLC_AM_RECEIVER_H__ -# define __RLC_AM_RECEIVER_H__ -/*! \fn signed int rlc_am_get_data_pdu_infos( const protocol_ctxt_t* const ctxt_pP, const rlc_am_entity_t * const rlc_pP,rlc_am_pdu_sn_10_t* headerP, int16_t sizeP, rlc_am_pdu_info_t* pdu_infoP) -* \brief Extract PDU informations (header fields, data size, etc) from the serialized PDU. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] headerP RLC AM header PDU pointer. -* \param[in] sizeP Size of RLC AM PDU. -* \param[in] pdu_infoP Structure containing extracted informations from PDU. -* \return 0 if no error was encountered during the parsing of the PDU, else -1; -*/ -signed int rlc_am_get_data_pdu_infos( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t * const rlc_pP, - rlc_am_pdu_sn_10_t* headerP, - int16_t sizeP, - rlc_am_pdu_info_t* pdu_infoP); - -/*! \fn void rlc_am_display_data_pdu_infos(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP, rlc_am_pdu_info_t* pdu_infoP) -* \brief Display RLC AM PDU informations. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] pdu_infoP Structure containing extracted informations of a PDU. -*/ -void rlc_am_display_data_pdu_infos(const protocol_ctxt_t* const ctxt_pP,rlc_am_entity_t * const rlc_pP, rlc_am_pdu_info_t* pdu_infoP); - -/*! \fn void rlc_am_rx_update_vr_ms(const protocol_ctxt_t* const ctxt_pP,rlc_am_entity_t * const rlc_pP,mem_block_t* tb_pP) -* \brief Update RLC AM protocol variable VR(MS). -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] tb_pP PDU embedded in a mem_block_t struct. -* \note It is assumed that the sequence number of the transport block is equal to VR(MS) -*/ -void rlc_am_rx_update_vr_ms(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP, mem_block_t* tb_pP); - -/*! \fn void rlc_am_rx_update_vr_r (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP,mem_block_t* tb_pP) -* \brief Update RLC AM protocol variable VR(R). -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] tb_pP PDU embedded in a mem_block_t struct. -* \note It is assumed that the sequence number of the transport block is equal to VR(R) -*/ -void rlc_am_rx_update_vr_r (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP, mem_block_t* tb_pP); - -/*! \fn void rlc_am_receive_routing (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP, struct mac_data_ind data_indP) -* \brief Convert transport blocks received from MAC layer into RLC AM PDUs, and dispatch to the right processing block these PDUS upon their type (CONTROL/DATA). -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] data_indP Transport blocks received from MAC layer. -*/ -void rlc_am_receive_routing (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP, struct mac_data_ind data_indP); - -/*! \fn void rlc_am_receive_process_data_pdu (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP, mem_block_t* tb_pP, uint8_t* first_byteP, uint16_t tb_size_in_bytesP) -* \brief Process an incoming data PDU received from MAC layer. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] tb_pP PDU embedded in a mem_block_t struct. -* \param[in] first_byteP Pointer on first byte of the PDU. -* \param[in] tb_size_in_bytesP Transport block size in bytes (same as PDU size in bytes). -*/ -void rlc_am_receive_process_data_pdu (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlc_pP, mem_block_t* tb_pP, uint8_t* first_byteP, - uint16_t tb_size_in_bytesP); -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c deleted file mode 100644 index 7129307739a376f470b6c12ce91422bf67fb8525..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c +++ /dev/null @@ -1,977 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_RETRANSMIT_C 1 -//----------------------------------------------------------------------------- -//#include "rtos_header.h" -//----------------------------------------------------------------------------- -#include "rlc_am.h" -#include "rlc.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" -//----------------------------------------------------------------------------- -bool rlc_am_nack_pdu(const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - const rlc_sn_t snP, - const rlc_sn_t prev_nack_snP, - sdu_size_t so_startP, - sdu_size_t so_endP) -{ - // 5.2.1 Retransmission - // ... - // When an AMD PDU or a portion of an AMD PDU is considered for retransmission, the transmitting side of the AM - // RLC entity shall: - // - if the AMD PDU is considered for retransmission for the first time: - // - set the RETX_COUNT associated with the AMD PDU to zero; - // - else, if it (the AMD PDU or the portion of the AMD PDU that is considered for retransmission) is not pending - // for retransmission already, or a portion of it is not pending for retransmission already: - // - increment the RETX_COUNT; - // - if RETX_COUNT = maxRetxThreshold: - // - indicate to upper layers that max retransmission has been reached. - - - 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; - bool status = true; - bool retx_count_increment = false; - sdu_size_t pdu_data_to_retx = 0; - - if (mb_p != NULL) { - //assert(so_startP <= so_endP); - if(so_startP > so_endP) { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[NACK-PDU] ERROR NACK MISSING PDU, so_startP %d, so_endP %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),so_startP, so_endP); - status = false; - } - // Handle full PDU NACK first - else if ((so_startP == 0) && (so_endP == 0x7FFF)) { - if ((prev_nack_snP != snP) && (tx_data_pdu_buffer_p->flags.ack == 0) && (tx_data_pdu_buffer_p->flags.max_retransmit == 0)) { - pdu_data_to_retx = tx_data_pdu_buffer_p->payload_size; - /* Increment VtReTxNext if this is the first NACK or if some segments have already been transmitted */ - if ((tx_data_pdu_buffer_p->flags.retransmit == 0) || (tx_data_pdu_buffer_p->nack_so_start)) - retx_count_increment = true; - - tx_data_pdu_buffer_p->nack_so_start = 0; - tx_data_pdu_buffer_p->num_holes = 0; - tx_data_pdu_buffer_p->retx_hole_index = 0; - tx_data_pdu_buffer_p->nack_so_stop = tx_data_pdu_buffer_p->payload_size - 1; - #if TRACE_RLC_AM_HOLE - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[HOLE] SN %04d GLOBAL NACK 0->%05d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - snP, - so_stopP); - #endif - //assert(tx_data_pdu_buffer_p->nack_so_start < tx_data_pdu_buffer_p->payload_size); - if(tx_data_pdu_buffer_p->nack_so_start >= tx_data_pdu_buffer_p->payload_size){ - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[NACK-PDU] ERROR NACK MISSING PDU, nack_so_start %d, payload_size %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),tx_data_pdu_buffer_p->nack_so_start, tx_data_pdu_buffer_p->payload_size); - status = false; - } - } - else { - status = false; - } - } - else if (tx_data_pdu_buffer_p->flags.max_retransmit == 0) { - // Handle Segment offset - if (so_endP == 0x7FFF) { - so_endP = tx_data_pdu_buffer_p->payload_size - 1; - } - - // Check consistency - if ((so_startP <= so_endP) && (so_endP < tx_data_pdu_buffer_p->payload_size)) { - if (prev_nack_snP != snP) { - /* New NACK_SN with SO */ - /* check whether a new segment is to be placed in Retransmission Buffer, then increment vrReTx */ - if ((tx_data_pdu_buffer_p->flags.retransmit == 0) || (so_startP < tx_data_pdu_buffer_p->nack_so_start)) - retx_count_increment = true; - - tx_data_pdu_buffer_p->num_holes = 1; - tx_data_pdu_buffer_p->retx_hole_index = 0; - tx_data_pdu_buffer_p->hole_so_start[0] = so_startP; - tx_data_pdu_buffer_p->hole_so_stop[0] = so_endP; - tx_data_pdu_buffer_p->nack_so_start = so_startP; - tx_data_pdu_buffer_p->nack_so_stop = so_endP; - pdu_data_to_retx = so_endP - so_startP + 1; - - } - else if ((tx_data_pdu_buffer_p->num_holes) && (tx_data_pdu_buffer_p->num_holes < RLC_AM_MAX_HOLES_REPORT_PER_PDU)) { - /* New SOStart/SOEnd for the same NACK_SN than before */ - /* check discontinuity */ - if (so_startP > tx_data_pdu_buffer_p->hole_so_stop[tx_data_pdu_buffer_p->num_holes - 1]) { - tx_data_pdu_buffer_p->hole_so_start[tx_data_pdu_buffer_p->num_holes] = so_startP; - tx_data_pdu_buffer_p->hole_so_stop[tx_data_pdu_buffer_p->num_holes] = so_endP; - tx_data_pdu_buffer_p->nack_so_stop = so_endP; - tx_data_pdu_buffer_p->num_holes ++; - pdu_data_to_retx = so_endP - so_startP + 1; - } else { - status = false; - } - } else { - status = false; - } - } - else { - status = false; - } - } else { - status = false; - } - - if (status) { - tx_data_pdu_buffer_p->flags.nack = 1; - if ((retx_count_increment) && (tx_data_pdu_buffer_p->retx_count == tx_data_pdu_buffer_p->retx_count_next)) { - tx_data_pdu_buffer_p->retx_count_next ++; - } - if (tx_data_pdu_buffer_p->flags.retransmit == 1) { - if (prev_nack_snP != snP) { - /* if first process of this NACK_SN and data already pending for retx */ - rlc_pP->retrans_num_bytes_to_retransmit += (pdu_data_to_retx - tx_data_pdu_buffer_p->retx_payload_size); - tx_data_pdu_buffer_p->retx_payload_size = pdu_data_to_retx; - } - else if (tx_data_pdu_buffer_p->num_holes > 1) { - /* Segment case : SOStart and SOEnd already received for same NACK_SN */ - /* filter case where a NACK_SN is received twice with SO first time and no SO second time */ - rlc_pP->retrans_num_bytes_to_retransmit += pdu_data_to_retx; - tx_data_pdu_buffer_p->retx_payload_size += pdu_data_to_retx; - } - } - else { - tx_data_pdu_buffer_p->flags.retransmit = 1; - rlc_pP->retrans_num_bytes_to_retransmit += pdu_data_to_retx; - tx_data_pdu_buffer_p->retx_payload_size = pdu_data_to_retx; - rlc_pP->retrans_num_pdus ++; - } - } - } else { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[NACK-PDU] ERROR NACK MISSING PDU SN %05d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - snP); - status = false; - } - - return status; -} -//----------------------------------------------------------------------------- -void rlc_am_ack_pdu(const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - const rlc_sn_t snP, - bool free_pdu) -{ - 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]; - - tx_data_pdu_buffer->flags.retransmit = 0; - - if (mb_p != NULL) { - if (free_pdu) { - free_mem_block(mb_p, __func__); - 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, - tx_data_pdu_buffer->retx_count); - } - - if (tx_data_pdu_buffer->retx_payload_size) { -//Assertion(eNB)_PRAN_DesignDocument_annex No.768 - if(tx_data_pdu_buffer->flags.ack != 0) - { - LOG_E(RLC, "RLC AM Rx Status Report sn=%d acked twice but is pending for Retx vtA=%d vtS=%d LcId=%d\n", - snP, rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - return; - } -/* - AssertFatal (tx_data_pdu_buffer->flags.ack == 0, - "RLC AM Rx Status Report sn=%d acked twice but is pending for Retx vtA=%d vtS=%d LcId=%d\n", - snP, rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); -*/ - 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 --; - } - - } else { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[ACK-PDU] WARNING ACK PDU SN %05d -> NO PDU TO ACK\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - snP); - - if (mb_p != NULL) { - free_mem_block(mb_p, __func__); - tx_data_pdu_buffer->mem_block = NULL; - } - } - tx_data_pdu_buffer->flags.ack = 1; - tx_data_pdu_buffer->flags.transmitted = 0; - tx_data_pdu_buffer->flags.retransmit = 0; - -} -//----------------------------------------------------------------------------- -mem_block_t* rlc_am_retransmit_get_copy ( - const protocol_ctxt_t* const ctxt_pP, - 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 % RLC_AM_WINDOW_SIZE].mem_block; -//Assertion(eNB)_PRAN_DesignDocument_annex No.784 - if(mb_original_p == NULL) - { - LOG_E(RLC,"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); - return NULL; - } -/* - 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_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); - mem_block_t* mb_copy = get_free_mem_block(size, __func__); - if(mb_copy == NULL) return NULL; - memcpy(mb_copy->data, mb_original_p->data, size); - - rlc_am_pdu_sn_10_t *pdu_p = (rlc_am_pdu_sn_10_t*) (&mb_copy->data[sizeof(struct mac_tb_req)]); - ((struct mac_tb_req*)(mb_copy->data))->data_ptr = (uint8_t*)pdu_p; - - return mb_copy; -} - -//----------------------------------------------------------------------------- -mem_block_t* rlc_am_retransmit_get_am_segment( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - rlc_am_tx_data_pdu_management_t *const pdu_mngt, - sdu_size_t * const payload_sizeP /* in-out*/) -{ - int16_t sdus_segment_size[RLC_AM_MAX_SDU_IN_PDU]; - mem_block_t* mb_original_p = pdu_mngt->mem_block; - mem_block_t* mem_pdu_segment_p = NULL; - uint8_t *pdu_original_header_p = NULL; - uint8_t *pdu_segment_header_p = NULL; - sdu_size_t retx_so_start,retx_so_stop; //starting and ending SO for retransmission in this PDU - rlc_sn_t sn = pdu_mngt->sn; - uint16_t header_so_part; - bool fi_start, fi_end; - uint8_t sdu_index = 0; - uint8_t sdu_segment_index = 0; - uint8_t num_LIs_pdu_segment = pdu_mngt->nb_sdus - 1; - uint8_t li_bit_offset = 4; /* toggle between 0 and 4 */ - uint8_t li_jump_offset = 1; /* toggle between 1 and 2 */ - -//Assertion(eNB)_PRAN_DesignDocument_annex No.774 - if(mb_original_p == NULL) - { - LOG_E(RLC,"RLC AM PDU Segment Error: Empty block sn=%d vtA=%d vtS=%d LcId=%d !\n", - sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - return NULL; - } -/* - AssertFatal (mb_original_p != NULL, "RLC AM PDU Segment Error: Empty block sn=%d vtA=%d vtS=%d LcId=%d !\n", - sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); -*/ -//Assertion(eNB)_PRAN_DesignDocument_annex No.775 - if(pdu_mngt->payload != mb_original_p->data + sizeof(struct mac_tb_req) + pdu_mngt->header_and_payload_size - pdu_mngt->payload_size) - { - LOG_E(RLC,"RLC AM PDU Segment Error: Inconsistent data pointers p1=%p p2=%p sn = %d total size = %d data size = %d LcId=%d !\n", - pdu_mngt->payload,mb_original_p->data + sizeof(struct mac_tb_req),pdu_mngt->header_and_payload_size,pdu_mngt->payload_size,sn,rlc_pP->channel_id); - return NULL; - } -/* - AssertFatal (pdu_mngt->payload == mb_original_p->data + sizeof(struct mac_tb_req) + pdu_mngt->header_and_payload_size - pdu_mngt->payload_size, - "RLC AM PDU Segment Error: Inconsistent data pointers p1=%p p2=%p sn = %d total size = %d data size = %d LcId=%d !\n", - pdu_mngt->payload,mb_original_p->data + sizeof(struct mac_tb_req),pdu_mngt->header_and_payload_size,pdu_mngt->payload_size,sn,rlc_pP->channel_id); -*/ - /* Init ReTx Hole list if not configured, ie the whole PDU has to be retransmitted */ - if (pdu_mngt->num_holes == 0) - { -//Assertion(eNB)_PRAN_DesignDocument_annex No.776 - if(pdu_mngt->retx_payload_size != pdu_mngt->payload_size) - { - LOG_E(RLC,"RLC AM PDU ReTx Segment: Expecting full PDU size ReTxSize=%d DataSize=%d sn=%d vtA=%d vtS=%d LcId=%d !\n", - pdu_mngt->retx_payload_size,pdu_mngt->payload_size,sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - return NULL; - } -/* - AssertFatal (pdu_mngt->retx_payload_size == pdu_mngt->payload_size,"RLC AM PDU ReTx Segment: Expecting full PDU size ReTxSize=%d DataSize=%d sn=%d vtA=%d vtS=%d LcId=%d !\n", - pdu_mngt->retx_payload_size,pdu_mngt->payload_size,sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); -*/ - pdu_mngt->retx_hole_index = 0; - pdu_mngt->hole_so_start[0] = 0; - pdu_mngt->hole_so_stop[0] = pdu_mngt->payload_size - 1; - pdu_mngt->num_holes = 1; - } - - /* Init SO Start and SO Stop */ - retx_so_start = pdu_mngt->hole_so_start[pdu_mngt->retx_hole_index]; - retx_so_stop = pdu_mngt->hole_so_stop[pdu_mngt->retx_hole_index]; -//Assertion(eNB)_PRAN_DesignDocument_annex No.777 - if((retx_so_start > retx_so_stop) || (retx_so_stop - retx_so_start + 1 > pdu_mngt->payload_size)) - { - LOG_E(RLC,"RLC AM Tx PDU Segment Data SO Error: retx_so_start=%d retx_so_stop=%d OriginalPDUDataLength=%d sn=%d LcId=%d!\n", - retx_so_start,retx_so_stop,pdu_mngt->payload_size,sn,rlc_pP->channel_id); - return NULL; - } -/* - AssertFatal ((retx_so_start <= retx_so_stop) && (retx_so_stop - retx_so_start + 1 <= pdu_mngt->payload_size), - "RLC AM Tx PDU Segment Data SO Error: retx_so_start=%d retx_so_stop=%d OriginalPDUDataLength=%d sn=%d LcId=%d!\n", - retx_so_start,retx_so_stop,pdu_mngt->payload_size,sn,rlc_pP->channel_id); -*/ - /* Init FI to the same value as original PDU */ - fi_start = (!(RLC_AM_PDU_GET_FI_START(*(pdu_mngt->first_byte)))); - fi_end = (!(RLC_AM_PDU_GET_FI_END(*(pdu_mngt->first_byte)))); - - /* Handle no LI case first */ - if (num_LIs_pdu_segment == 0) - { - /* Bound retx_so_stop to available TBS */ - if (retx_so_stop - retx_so_start + 1 + RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE > rlc_pP->nb_bytes_requested_by_mac) - { - retx_so_stop = retx_so_start + rlc_pP->nb_bytes_requested_by_mac - RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE - 1; - } - - *payload_sizeP = retx_so_stop - retx_so_start + 1; - - mem_pdu_segment_p = get_free_mem_block((*payload_sizeP + RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE + sizeof(struct mac_tb_req)), __func__); - if(mem_pdu_segment_p == NULL) return NULL; - pdu_segment_header_p = (uint8_t *)&mem_pdu_segment_p->data[sizeof(struct mac_tb_req)]; - ((struct mac_tb_req*)(mem_pdu_segment_p->data))->data_ptr = pdu_segment_header_p; - ((struct mac_tb_req*)(mem_pdu_segment_p->data))->tb_size = RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE + *payload_sizeP; - - /* clear all PDU segment */ - memset(pdu_segment_header_p, 0, *payload_sizeP + RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE); - /* copy data part */ - memcpy(pdu_segment_header_p + RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE, pdu_mngt->payload + retx_so_start, *payload_sizeP); - - /* Set FI part to false if SO Start and SO End are different from PDU boundaries */ - if (retx_so_start) - { - fi_start = false; - } - if (retx_so_stop < pdu_mngt->payload_size - 1) - { - fi_end = false; - } - - /* Header content is filled at the end */ - } - else - { - /* Step 1 */ - /* Find the SDU index in the original PDU containing retx_so_start */ - sdu_size_t sdu_size = 0; - sdu_size_t data_size = 0; - *payload_sizeP = 0; - sdu_size_t header_segment_length = RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE; - pdu_original_header_p = pdu_mngt->first_byte + 2; - li_bit_offset = 4; /* toggle between 0 and 4 */ - li_jump_offset = 1; /* toggle between 1 and 2 */ - uint16_t temp_read = ((*pdu_original_header_p) << 8) | (*(pdu_original_header_p + 1)); - - - /* Read first LI */ - sdu_size = RLC_AM_PDU_GET_LI(temp_read,li_bit_offset); - pdu_original_header_p += li_jump_offset; - li_bit_offset ^= 0x4; - li_jump_offset ^= 0x3; - data_size += sdu_size; - sdu_index = 1; - - /* Loop on all original LIs */ - while ((data_size < retx_so_start + 1) && (sdu_index < pdu_mngt->nb_sdus)) - { - if (sdu_index < pdu_mngt->nb_sdus - 1) - { - temp_read = ((*pdu_original_header_p) << 8) | (*(pdu_original_header_p + 1)); - sdu_size = RLC_AM_PDU_GET_LI(temp_read,li_bit_offset); - pdu_original_header_p += li_jump_offset; - li_bit_offset ^= 0x4; - li_jump_offset ^= 0x3; - data_size += sdu_size; - } - else - { - /* if retx_so_start is still not included then set data_size with full original PDU data size */ - /* Set fi_start to false in this case */ - data_size = pdu_mngt->payload_size; - } - sdu_index ++; - } - - if (retx_so_start == data_size) - { - /* Set FI Start if retx_so_start = cumulated data size */ - fi_start = true; - /* there must be at least one SDU more */ -//Assertion(eNB)_PRAN_DesignDocument_annex No.778 - if(sdu_index >= pdu_mngt->nb_sdus) - { - LOG_E(RLC,"RLC AM Tx PDU Segment Error: sdu_index=%d nb_sdus=%d sn=%d LcId=%d !\n", - sdu_index,pdu_mngt->nb_sdus,sn,rlc_pP->channel_id); - return NULL; - } -/* - AssertFatal (sdu_index < pdu_mngt->nb_sdus, "RLC AM Tx PDU Segment Error: sdu_index=%d nb_sdus=%d sn=%d LcId=%d !\n", - sdu_index,pdu_mngt->nb_sdus,sn,rlc_pP->channel_id); -*/ - if (sdu_index < pdu_mngt->nb_sdus - 1) - { - temp_read = ((*pdu_original_header_p) << 8) | (*(pdu_original_header_p + 1)); - sdu_size = RLC_AM_PDU_GET_LI(temp_read,li_bit_offset); - pdu_original_header_p += li_jump_offset; - li_bit_offset ^= 0x4; - li_jump_offset ^= 0x3; - data_size += sdu_size; - } - else - { - /* It was the last LI, then set data_size to full original PDU size */ - data_size = pdu_mngt->payload_size; - } - /* Go to next SDU */ - sdu_index ++; - } - else if (retx_so_start != 0) - { - /* in all other cases set fi_start to false if it SO Start is not 0 */ - fi_start = false; - } - - /* Set first SDU portion of the segment */ - sdus_segment_size[0] = data_size - retx_so_start; - - /* Check if so end is in the first SDU portion */ - if (sdus_segment_size[0] >= retx_so_stop - retx_so_start + 1) - { - sdus_segment_size[0] = retx_so_stop - retx_so_start + 1; - *payload_sizeP = sdus_segment_size[0]; - num_LIs_pdu_segment = 0; - } - - /* Bound first SDU segment to available TBS if necessary */ - if (sdus_segment_size[0] + RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE >= rlc_pP->nb_bytes_requested_by_mac) - { - sdus_segment_size[0] = rlc_pP->nb_bytes_requested_by_mac - RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE; - *payload_sizeP = sdus_segment_size[0]; - num_LIs_pdu_segment = 0; - } - - - /* Now look for the end if it was not set previously */ - if (*payload_sizeP == 0) - { - sdu_segment_index ++; - while ((sdu_index < pdu_mngt->nb_sdus) && (data_size < retx_so_stop + 1)) - { - if (sdu_index < pdu_mngt->nb_sdus - 1) - { - temp_read = ((*pdu_original_header_p) << 8) | (*(pdu_original_header_p + 1)); - sdu_size = RLC_AM_PDU_GET_LI(temp_read,li_bit_offset); - pdu_original_header_p += li_jump_offset; - li_bit_offset ^= 0x4; - li_jump_offset ^= 0x3; - data_size += sdu_size; - } - else - { - sdu_size = pdu_mngt->payload_size - data_size; - data_size = pdu_mngt->payload_size; - } - - sdus_segment_size[sdu_segment_index] = sdu_size; - sdu_index ++; - sdu_segment_index ++; - } - - - if (data_size > retx_so_stop + 1) - { - sdus_segment_size[sdu_segment_index - 1] = retx_so_stop - (data_size - sdu_size) + 1; - } - - /* Set number of LIs in the segment */ - num_LIs_pdu_segment = sdu_segment_index - 1; -//Assertion(eNB)_PRAN_DesignDocument_annex No.779 - if(num_LIs_pdu_segment > pdu_mngt->nb_sdus - 1) - { - LOG_E(RLC, "RLC AM Tx PDU Segment Data Error: nbLISegment=%d nbLIPDU=%d sn=%d LcId=%d !\n", - num_LIs_pdu_segment,pdu_mngt->nb_sdus - 1,sn,rlc_pP->channel_id); - return NULL; - } -/* - AssertFatal (num_LIs_pdu_segment <= pdu_mngt->nb_sdus - 1, "RLC AM Tx PDU Segment Data Error: nbLISegment=%d nbLIPDU=%d sn=%d LcId=%d !\n", - num_LIs_pdu_segment,pdu_mngt->nb_sdus - 1,sn,rlc_pP->channel_id); -*/ - /* Bound to available TBS taking into account min PDU segment header*/ - sdu_segment_index = 0; - while ((sdu_segment_index < num_LIs_pdu_segment + 1) && (rlc_pP->nb_bytes_requested_by_mac > *payload_sizeP + RLC_AM_PDU_SEGMENT_HEADER_SIZE(sdu_segment_index))) - { -//Assertion(eNB)_PRAN_DesignDocument_annex No.780 - if(sdus_segment_size[sdu_segment_index] <= 0) - { - LOG_E(RLC, "RLC AM Tx PDU Segment Data Error: EMpty LI index=%d numLISegment=%d numLIPDU=%d PDULength=%d SOStart=%d SOStop=%d sn=%d LcId=%d !\n", - sdu_segment_index,num_LIs_pdu_segment,pdu_mngt->nb_sdus - 1,pdu_mngt->payload_size,retx_so_start,retx_so_stop,sn,rlc_pP->channel_id); - sdu_segment_index++; - continue; - } -/* - AssertFatal (sdus_segment_size[sdu_segment_index] > 0, "RLC AM Tx PDU Segment Data Error: EMpty LI index=%d numLISegment=%d numLIPDU=%d PDULength=%d SOStart=%d SOStop=%d sn=%d LcId=%d !\n", - sdu_segment_index,num_LIs_pdu_segment,pdu_mngt->nb_sdus - 1,pdu_mngt->payload_size,retx_so_start,retx_so_stop,sn,rlc_pP->channel_id); -*/ - /* Add next sdu_segment_index to data part */ - if (RLC_AM_PDU_SEGMENT_HEADER_SIZE(sdu_segment_index) + (*payload_sizeP) + sdus_segment_size[sdu_segment_index] <= rlc_pP->nb_bytes_requested_by_mac) - { - (*payload_sizeP) += sdus_segment_size[sdu_segment_index]; - } - else - { - /* bound to available TBS size */ - sdus_segment_size[sdu_segment_index] = rlc_pP->nb_bytes_requested_by_mac - RLC_AM_PDU_SEGMENT_HEADER_SIZE(sdu_segment_index) - (*payload_sizeP); - (*payload_sizeP) += sdus_segment_size[sdu_segment_index]; - } - header_segment_length = RLC_AM_PDU_SEGMENT_HEADER_SIZE(sdu_segment_index); - sdu_segment_index ++; - } - - num_LIs_pdu_segment = sdu_segment_index - 1; - } - - - /* update retx_so_stop */ - retx_so_stop = retx_so_start + (*payload_sizeP) - 1; -//Assertion(eNB)_PRAN_DesignDocument_annex No.781 - if((retx_so_stop > pdu_mngt->payload_size - 1) || (retx_so_stop - retx_so_start + 1 >= pdu_mngt->payload_size)) - { - LOG_E(RLC,"RLC AM Tx PDU Segment Data Error: retx_so_stop=%d OriginalPDUDataLength=%d SOStart=%d SegmentLength=%d numLISegment=%d numLIPDU=%d sn=%d LcId=%d !\n", - retx_so_stop,pdu_mngt->payload_size,retx_so_start,*payload_sizeP,num_LIs_pdu_segment,pdu_mngt->nb_sdus - 1,sn,rlc_pP->channel_id); - return NULL; - } -/* - AssertFatal ((retx_so_stop <= pdu_mngt->payload_size - 1) && (retx_so_stop - retx_so_start + 1 < pdu_mngt->payload_size), - "RLC AM Tx PDU Segment Data Error: retx_so_stop=%d OriginalPDUDataLength=%d SOStart=%d SegmentLength=%d numLISegment=%d numLIPDU=%d sn=%d LcId=%d !\n", - retx_so_stop,pdu_mngt->payload_size,retx_so_start,*payload_sizeP,num_LIs_pdu_segment,pdu_mngt->nb_sdus - 1,sn,rlc_pP->channel_id); -*/ - /* init FI End to false if retx_so_stop is not end of PDU */ - if (retx_so_stop != pdu_mngt->payload_size - 1) - { - fi_end = false; - } - - /* Check consistency between sdus_segment_size and payload_sizeP */ - /* And Set FI End if retx_so_stop = cumulated data size and this is not last SDU */ - data_size = 0; - for (int i = 0; i < num_LIs_pdu_segment + 1; i++) - { - data_size += sdus_segment_size[i]; - if ((retx_so_stop == data_size - 1) && (i < num_LIs_pdu_segment)) - { - fi_end = true; - } - } -//Assertion(eNB)_PRAN_DesignDocument_annex No.782 - if(data_size != *payload_sizeP) - { - LOG_E(RLC,"RLC AM Tx PDU Segment Data Error: SduSum=%d Data=%d sn=%d LcId=%d !\n", - data_size,*payload_sizeP,sn,rlc_pP->channel_id); - return NULL; - } -/* - AssertFatal (data_size == *payload_sizeP, "RLC AM Tx PDU Segment Data Error: SduSum=%d Data=%d sn=%d LcId=%d !\n", - data_size,*payload_sizeP,sn,rlc_pP->channel_id); -*/ - - - /* Allocation */ -//Assertion(eNB)_PRAN_DesignDocument_annex No.783 - if(header_segment_length + *payload_sizeP > pdu_mngt->header_and_payload_size + 2) - { - LOG_E(RLC, "RLC AM PDU Segment Error: Hdr=%d Data=%d Original Hdr+Data =%d sn=%d LcId=%d !\n", - header_segment_length,*payload_sizeP,pdu_mngt->header_and_payload_size,sn,rlc_pP->channel_id); - return NULL; - } -/* - AssertFatal (header_segment_length + *payload_sizeP <= pdu_mngt->header_and_payload_size + 2, "RLC AM PDU Segment Error: Hdr=%d Data=%d Original Hdr+Data =%d sn=%d LcId=%d !\n", - header_segment_length,*payload_sizeP,pdu_mngt->header_and_payload_size,sn,rlc_pP->channel_id); -*/ - mem_pdu_segment_p = get_free_mem_block((*payload_sizeP + header_segment_length + sizeof(struct mac_tb_req)), __func__); - if(mem_pdu_segment_p == NULL) return NULL; - pdu_segment_header_p = (uint8_t *)&mem_pdu_segment_p->data[sizeof(struct mac_tb_req)]; - ((struct mac_tb_req*)(mem_pdu_segment_p->data))->data_ptr = pdu_segment_header_p; - ((struct mac_tb_req*)(mem_pdu_segment_p->data))->tb_size = header_segment_length + *payload_sizeP; - - /* clear all PDU segment */ - memset(pdu_segment_header_p, 0, *payload_sizeP + header_segment_length); - /* copy data part */ - memcpy(pdu_segment_header_p + header_segment_length, pdu_mngt->payload + retx_so_start, *payload_sizeP); - } - - /* Last step : update contexts and fill PDU Segment Header */ - if (mem_pdu_segment_p != NULL) - { - /* Update PDU Segment contexts */ - if (*payload_sizeP == pdu_mngt->hole_so_stop[pdu_mngt->retx_hole_index] - pdu_mngt->hole_so_start[pdu_mngt->retx_hole_index] + 1) - { - /* All data in the segment are transmitted : switch to next one */ - pdu_mngt->retx_hole_index ++; - if (pdu_mngt->retx_hole_index < pdu_mngt->num_holes) - { - /* Set min SOStart to the value of next hole : assumption is holes are ordered by increasing SOStart */ - pdu_mngt->nack_so_start = pdu_mngt->hole_so_start[pdu_mngt->retx_hole_index]; - } - else - { - /* no more scheduled Retx: reset values */ - /* Retx size is reset in the calling function */ - pdu_mngt->num_holes = 0; - pdu_mngt->retx_hole_index = 0; - pdu_mngt->nack_so_start = 0; - } - } - else - { - /* not all segment data could be transmitted, just update SoStart */ - pdu_mngt->hole_so_start[pdu_mngt->retx_hole_index] += (*payload_sizeP); - pdu_mngt->nack_so_start = pdu_mngt->hole_so_start[pdu_mngt->retx_hole_index]; - } - - /* Content is supposed to be init with 0 so with FIStart=FIEnd=true */ - RLC_AM_PDU_SET_D_C(*pdu_segment_header_p); - RLC_AM_PDU_SET_RF(*pdu_segment_header_p); - /* Change FI */ - if (!fi_start) - { - // Set to not starting - (*pdu_segment_header_p) |= (1 << (RLC_AM_PDU_FI_OFFSET + 1)); - } - if (!fi_end) - { - // Set to not starting - (*pdu_segment_header_p) |= (1 << (RLC_AM_PDU_FI_OFFSET)); - } - /* Set SN */ - (*pdu_segment_header_p) |= ((sn >> 8) & 0x3); - (*(pdu_segment_header_p + 1)) |= (sn & 0xFF); - - /* Segment Offset */ - header_so_part = retx_so_start; - - /* Last Segment Flag (LSF) */ - if (retx_so_stop == pdu_mngt->payload_size - 1) - { - RLC_AM_PDU_SET_LSF(header_so_part); - } - - /* Store SO bytes */ - * (pdu_segment_header_p + 2) = (header_so_part >> 8) & 0xFF; - * (pdu_segment_header_p + 3) = header_so_part & 0xFF; - - /* Fill LI part */ - if (num_LIs_pdu_segment) - { - uint16_t index = 0; - uint16_t temp = 0; - /* Set Extension bit in first byte */ - RLC_AM_PDU_SET_E(*pdu_segment_header_p); - - /* loop on nb of LIs */ - pdu_segment_header_p += RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE; - li_bit_offset = 4; /* toggle between 0 and 4 */ - li_jump_offset = 1; /* toggle between 1 and 2 */ - - while (index < num_LIs_pdu_segment) - { - /* Set E bit for next LI if present */ - if (index < num_LIs_pdu_segment - 1) - RLC_SET_BIT(temp,li_bit_offset + RLC_AM_LI_BITS); - /* Set LI */ - RLC_AM_PDU_SET_LI(temp,sdus_segment_size[index],li_bit_offset); - *pdu_segment_header_p = temp >> 8; - *(pdu_segment_header_p + 1) = temp & 0xFF; - pdu_segment_header_p += li_jump_offset; - li_bit_offset ^= 0x4; - li_jump_offset ^= 0x3; - - temp = ((*pdu_segment_header_p) << 8) | (*(pdu_segment_header_p + 1)); - index ++; - } - } - } - else - { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RE-SEGMENT] OUT OF MEMORY PDU SN %04d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - sn); - } - - return mem_pdu_segment_p; -} - -//----------------------------------------------------------------------------- -void rlc_am_tx_buffer_display ( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP, - char* const message_pP) -{ - 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:", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - message_pP, - rlc_pP->vt_a, - rlc_pP->vt_s); - } else { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" Retransmission buffer VT(A)=%04d VT(S)=%04d:", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->vt_a, - rlc_pP->vt_s); - } - - while (rlc_pP->vt_s != sn) { - 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 (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, tx_data_pdu_buffer_p->header_and_payload_size, tx_data_pdu_buffer_p->payload_size, - tx_data_pdu_buffer_p->retx_count); - } - - 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<tx_data_pdu_buffer_p->num_holes; i++) { - //assert(i < RLC_AM_MAX_HOLES_REPORT_PER_PDU); - if(i >= RLC_AM_MAX_HOLES_REPORT_PER_PDU) { - LOG_E(RLC, "num_holes error. %d %d %d\n", tx_data_pdu_buffer_p->num_holes, i, RLC_AM_MAX_HOLES_REPORT_PER_PDU); - break; - } - 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]); - } - } - - loop++; - } - - sn = (sn + 1) & RLC_AM_SN_MASK; - } - - LOG_D(RLC, "\n"); -} - -//----------------------------------------------------------------------------- -mem_block_t * rlc_am_get_pdu_to_retransmit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP) -{ - rlc_sn_t sn = rlc_pP->vt_a; - rlc_sn_t sn_end = rlc_pP->vt_s; - mem_block_t* pdu_p = NULL; - mem_block_t* mb_p = NULL; - rlc_am_tx_data_pdu_management_t* tx_data_pdu_management; -//Assertion(eNB)_PRAN_DesignDocument_annex No.769 - if((rlc_pP->retrans_num_pdus <= 0) || (rlc_pP->vt_a == rlc_pP->vt_s)) - { - LOG_E(RLC, "RLC AM ReTx start process Error: NbPDUtoRetx=%d vtA=%d vtS=%d LcId=%d !\n", - rlc_pP->retrans_num_pdus,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - return NULL; - } -/* - AssertFatal ((rlc_pP->retrans_num_pdus > 0) && (rlc_pP->vt_a != rlc_pP->vt_s), "RLC AM ReTx start process Error: NbPDUtoRetx=%d vtA=%d vtS=%d LcId=%d !\n", - rlc_pP->retrans_num_pdus,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); -*/ - do - { - tx_data_pdu_management = &rlc_pP->tx_data_pdu_buffer[sn % RLC_AM_WINDOW_SIZE]; - if ((tx_data_pdu_management->flags.retransmit) && (tx_data_pdu_management->flags.max_retransmit == 0)) - { -//Assertion(eNB)_PRAN_DesignDocument_annex No.770 - if(tx_data_pdu_management->sn != sn) - { - LOG_E(RLC, "RLC AM ReTx PDU Error: SN Error pdu_sn=%d sn=%d vtA=%d vtS=%d LcId=%d !\n", - tx_data_pdu_management->sn,sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - } -//Assertion(eNB)_PRAN_DesignDocument_annex No.771 - else if(tx_data_pdu_management->flags.transmitted != 1) - { - LOG_E(RLC, "RLC AM ReTx PDU Error: State Error sn=%d vtA=%d vtS=%d LcId=%d !\n", - sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - } -//Assertion(eNB)_PRAN_DesignDocument_annex No.772 - else if(tx_data_pdu_management->retx_payload_size <= 0) - { - LOG_E(RLC, "RLC AM ReTx PDU Error: No Data to Retx sn=%d vtA=%d vtS=%d LcId=%d !\n", - sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - } - else - { -/* - AssertFatal (tx_data_pdu_management->sn == sn, "RLC AM ReTx PDU Error: SN Error pdu_sn=%d sn=%d vtA=%d vtS=%d LcId=%d !\n", - tx_data_pdu_management->sn,sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - AssertFatal (tx_data_pdu_management->flags.transmitted == 1, "RLC AM ReTx PDU Error: State Error sn=%d vtA=%d vtS=%d LcId=%d !\n", - sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - AssertFatal (tx_data_pdu_management->retx_payload_size > 0, "RLC AM ReTx PDU Error: No Data to Retx sn=%d vtA=%d vtS=%d LcId=%d !\n", - sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); -*/ - /* Either the whole RLC PDU is to be transmitted and there is enough MAC TBS or there is minimum TBS size for transmitting 1 AM PDU segment */ - if ((tx_data_pdu_management->retx_payload_size == tx_data_pdu_management->payload_size) && (rlc_pP->nb_bytes_requested_by_mac >= tx_data_pdu_management->header_and_payload_size)) - { - /* check maxretx is not hit */ - if (tx_data_pdu_management->retx_count_next <= rlc_pP->max_retx_threshold) - { - pdu_p = rlc_am_retransmit_get_copy(ctxt_pP, rlc_pP, sn); - - if (pdu_p != NULL) - { - rlc_pP->retrans_num_bytes_to_retransmit -= tx_data_pdu_management->retx_payload_size; - rlc_pP->retrans_num_pdus --; - tx_data_pdu_management->retx_payload_size = 0; - tx_data_pdu_management->flags.retransmit = 0; - - // update stats - rlc_pP->stat_tx_data_pdu += 1; - rlc_pP->stat_tx_retransmit_pdu += 1; - rlc_pP->stat_tx_retransmit_pdu_by_status += 1; - rlc_pP->stat_tx_data_bytes += tx_data_pdu_management->payload_size; - rlc_pP->stat_tx_retransmit_bytes += tx_data_pdu_management->payload_size; - rlc_pP->stat_tx_retransmit_bytes_by_status += tx_data_pdu_management->payload_size; - - } - } - else - { - // TO DO : RLC Notification to RRC + ReEstablishment procedure - tx_data_pdu_management->flags.max_retransmit = 1; - LOG_W(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RLC AM MAX RETX=%d] SN %04d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - tx_data_pdu_management->retx_count_next, - sn); - mb_p = rlc_pP->tx_data_pdu_buffer[sn % RLC_AM_WINDOW_SIZE].mem_block; - if(mb_p != NULL){ - free_mem_block(mb_p, __func__); - tx_data_pdu_management->mem_block = NULL; - tx_data_pdu_management->flags.retransmit = 0; - tx_data_pdu_management->flags.ack = 1; - tx_data_pdu_management->flags.transmitted = 0; - rlc_pP->retrans_num_bytes_to_retransmit -= tx_data_pdu_management->retx_payload_size; - tx_data_pdu_management->retx_payload_size = 0; - tx_data_pdu_management->num_holes = 0; - rlc_pP->retrans_num_pdus --; - } - } - } - else if (rlc_pP->nb_bytes_requested_by_mac >= 5) - { - /* Resegmentation case */ - /* check maxretx is not hit */ - if (tx_data_pdu_management->retx_count_next <= rlc_pP->max_retx_threshold) - { - sdu_size_t pdu_data_size = 0; - - pdu_p = rlc_am_retransmit_get_am_segment(ctxt_pP, rlc_pP, tx_data_pdu_management,&pdu_data_size); - - if (pdu_p != NULL) - { -//Assertion(eNB)_PRAN_DesignDocument_annex No.773 - if((tx_data_pdu_management->retx_payload_size < pdu_data_size)|| (rlc_pP->retrans_num_bytes_to_retransmit < pdu_data_size)) - { - LOG_E(RLC, "RLC AM ReTx PDU Segment Error: DataSize=%d PDUReTxsize=%d TotalReTxsize=%d sn=%d LcId=%d !\n", - pdu_data_size,tx_data_pdu_management->retx_payload_size,rlc_pP->retrans_num_bytes_to_retransmit,sn,rlc_pP->channel_id); - } - else - { -/* - AssertFatal ((tx_data_pdu_management->retx_payload_size >= pdu_data_size) && (rlc_pP->retrans_num_bytes_to_retransmit >= pdu_data_size), "RLC AM ReTx PDU Segment Error: DataSize=%d PDUReTxsize=%d TotalReTxsize=%d sn=%d LcId=%d !\n", - pdu_data_size,tx_data_pdu_management->retx_payload_size,rlc_pP->retrans_num_bytes_to_retransmit,sn,rlc_pP->channel_id); -*/ - tx_data_pdu_management->retx_payload_size -= pdu_data_size; - rlc_pP->retrans_num_bytes_to_retransmit -= pdu_data_size; - if (tx_data_pdu_management->retx_payload_size == 0) - { - rlc_pP->retrans_num_pdus --; - tx_data_pdu_management->retx_payload_size = 0; - tx_data_pdu_management->flags.retransmit = 0; - } - - // update stats - rlc_pP->stat_tx_data_pdu += 1; - rlc_pP->stat_tx_retransmit_pdu += 1; - rlc_pP->stat_tx_retransmit_pdu_by_status += 1; - rlc_pP->stat_tx_data_bytes += pdu_data_size; - rlc_pP->stat_tx_retransmit_bytes += pdu_data_size; - rlc_pP->stat_tx_retransmit_bytes_by_status += pdu_data_size; - - }//Assertion(eNB)_PRAN_DesignDocument_annex No.773 - } - } - else - { - // TO DO : RLC Notification to RRC + ReEstablishment procedure - tx_data_pdu_management->flags.max_retransmit = 1; - LOG_W(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RLC AM MAX RETX=%d] SN %04d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - tx_data_pdu_management->retx_count_next, - sn); - mb_p = rlc_pP->tx_data_pdu_buffer[sn % RLC_AM_WINDOW_SIZE].mem_block; - if(mb_p != NULL){ - free_mem_block(mb_p, __func__); - tx_data_pdu_management->mem_block = NULL; - tx_data_pdu_management->flags.retransmit = 0; - tx_data_pdu_management->flags.ack = 1; - tx_data_pdu_management->flags.transmitted = 0; - rlc_pP->retrans_num_bytes_to_retransmit -= tx_data_pdu_management->retx_payload_size; - tx_data_pdu_management->retx_payload_size = 0; - tx_data_pdu_management->num_holes = 0; - rlc_pP->retrans_num_pdus --; - } - } - } - - if (pdu_p != NULL) - { - /* check polling */ - rlc_am_pdu_sn_10_t* pdu_header_p = (rlc_am_pdu_sn_10_t*) (&pdu_p->data[sizeof(struct mac_tb_req)]); - rlc_am_pdu_polling(ctxt_pP, rlc_pP, pdu_header_p, tx_data_pdu_management->payload_size,false); - - tx_data_pdu_management->retx_count = tx_data_pdu_management->retx_count_next; - - break; - } - - }//Assertion(eNB)_PRAN_DesignDocument_annex No.770 No.771 No.772 - } - sn = RLC_AM_NEXT_SN(sn); - } while((sn != sn_end) && (rlc_pP->retrans_num_pdus > 0)); - - return pdu_p; -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.h deleted file mode 100644 index c34d06337da71763d9d27bf3a1bb46c8cbe8c4cc..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_retransmit.h -* \brief This file defines the prototypes of the functions dealing with the retransmission. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_internal_retransmit_impl_ RLC AM Retransmitter Internal Reference Implementation -* @ingroup _rlc_am_internal_impl_ -* @{ -*/ -# ifndef __RLC_AM_RETRANSMIT_H__ -# define __RLC_AM_RETRANSMIT_H__ -//----------------------------------------------------------------------------- -/*! \fn bool rlc_am_nack_pdu (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *rlcP, int16_t snP, int16_t prev_nack_snP,sdu_size_t so_startP, sdu_size_t so_endP) -* \brief The RLC AM PDU which have the sequence number snP is marked NACKed with segment offset fields. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] snP Sequence number of the PDU that is negative acknowledged. -* \param[in] prev_nack_snP Sequence number of previous PDU that is negative acknowledged. -* \param[in] so_startP Start of the segment offset of the PDU that . -* \param[in] so_endP Transport blocks received from MAC layer. -* \return OK/KO -* \note It may appear a new hole in the retransmission buffer depending on the segment offset informations. Depending on the state of the retransmission buffer, negative confirmation can be sent to higher layers about the drop by the RLC AM instance of a particular SDU. -*/ -bool rlc_am_nack_pdu(const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlcP, - const rlc_sn_t snP, - const rlc_sn_t prev_nack_snP, - sdu_size_t so_startP, - sdu_size_t so_endP); - -/*! \fn void rlc_am_ack_pdu (const protocol_ctxt_t* const ctxt_pP,rlc_am_entity_t *rlcP, rlc_sn_t snP) -* \brief The RLC AM PDU which have the sequence number snP is marked ACKed. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] snP Sequence number of the PDU that is acknowledged. -* \param[in] free_pdu Boolean indicating that the PDU can be freed because smaller than new vtA. -* \note Depending on the state of the retransmission buffer, positive confirmation can be sent to higher layers about the receiving by the peer RLC AM instance of a particular SDU. -*/ -void rlc_am_ack_pdu(const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlcP, - const rlc_sn_t snP, - bool free_pdu); - -/*! \fn mem_block_t* rlc_am_retransmit_get_copy (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *rlcP, rlc_sn_t snP) -* \brief The RLC AM PDU which have the sequence number snP is marked ACKed. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] snP Sequence number of the PDU to be copied. -* \return A copy of the PDU having sequence number equal to parameter snP. -*/ -mem_block_t* rlc_am_retransmit_get_copy ( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlcP, - const rlc_sn_t snP); -/*! \fn mem_block_t* rlc_am_retransmit_get_subsegment (const protocol_ctxt_t* const ctxt_pP,rlc_am_entity_t *rlcP,rlc_sn_t snP, sdu_size_t *sizeP) -* \brief The RLC AM PDU which have the sequence number snP is marked ACKed. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] snP Sequence number of the PDU to be copied. -* \param[in,out] sizeP Maximum size allowed for the subsegment, it is updated with the amount of bytes not used (sizeP[out] = sizeP[in] - size of segment). -* \return A copy of a segment of the PDU having sequence number equal to parameter snP. -*/ -mem_block_t* rlc_am_retransmit_get_subsegment ( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlcP, - const rlc_sn_t snP, - sdu_size_t *const sizeP); -/*! \fn mem_block_t* rlc_am_get_pdu_to_retransmit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* rlcP) -* \brief Find a PDU or PDU segment to retransmit. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \return A copy of the retransmitted PDU or PDU segment or NULL if TBS was not big enough -*/ -mem_block_t* rlc_am_get_pdu_to_retransmit( - const protocol_ctxt_t* const ctxt_pP, - - rlc_am_entity_t* const rlcP); -/*! \fn void rlc_am_retransmit_any_pdu(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* rlcP) -* \brief Retransmit any PDU in order to unblock peer entity, if no suitable PDU is found (depending on requested MAC size) to be retransmitted, then try to retransmit a subsegment of any PDU. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -*/ -void rlc_am_retransmit_any_pdu( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlcP); - -/*! \fn void rlc_am_tx_buffer_display (const protocol_ctxt_t* const ctxt_pP,rlc_am_entity_t* rlcP, char* message_pP) -* \brief Display the dump of the retransmission buffer. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] message_pP Message to be displayed along with the display of the dump of the retransmission buffer. -*/ -void rlc_am_tx_buffer_display ( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlcP, - char* const message_pP); -/** @} */ -# endif 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 deleted file mode 100644 index bd578abab2a817d0f97e34eb575d5930ea362cff..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c +++ /dev/null @@ -1,1297 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_RX_LIST_C 1 -//----------------------------------------------------------------------------- -#include "platform_types.h" -//----------------------------------------------------------------------------- -#include "assertions.h" -#include "list.h" -#include "rlc_am.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" - - -bool rlc_am_rx_check_vr_reassemble(const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP) -{ - mem_block_t* cursor_p = rlc_pP->receiver_buffer.head; - rlc_am_rx_pdu_management_t * pdu_cursor_mgnt_p = NULL; - sdu_size_t next_waited_so = 0; - bool reassemble = false; - - if (cursor_p != NULL) { - - rlc_am_pdu_info_t* pdu_info_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - rlc_usn_t sn_ref = pdu_info_p->sn; - - if (sn_ref != rlc_pP->vr_r) { - /* Case vrR has advanced from head : most likely case */ - - reassemble = true; - /* Handle first SN if it is made of PDU segments : set them all to be reassembled */ - if (pdu_info_p->rf) { - pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); - next_waited_so = 0; -//Assertion(eNB)_PRAN_DesignDocument_annex No.785 - if(pdu_cursor_mgnt_p->all_segments_received <= 0) - { - LOG_E(RLC, "AM Rx Check Reassembly head SN=%d with PDU segments != vrR=%d should be fully received LCID=%d\n", - sn_ref,rlc_pP->vr_r,rlc_pP->channel_id); - return false; - } -/* - AssertFatal(pdu_cursor_mgnt_p->all_segments_received > 0,"AM Rx Check Reassembly head SN=%d with PDU segments != vrR=%d should be fully received LCID=%d\n", - sn_ref,rlc_pP->vr_r,rlc_pP->channel_id); -*/ - while ((cursor_p != NULL) && (pdu_info_p->sn == sn_ref) && (pdu_info_p->so == next_waited_so)) { - if (pdu_cursor_mgnt_p->segment_reassembled == RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_NO) { - pdu_cursor_mgnt_p->segment_reassembled = RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_PENDING; - } - next_waited_so += pdu_info_p->payload_size; - cursor_p = cursor_p->next; - if (cursor_p != NULL) { - pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); - pdu_info_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - } - } - } - - /* Now jump up to vrR */ - while ((RLC_AM_DIFF_SN(pdu_info_p->sn,sn_ref) < RLC_AM_DIFF_SN(rlc_pP->vr_r,sn_ref)) && (cursor_p != NULL)) { - cursor_p = cursor_p->next; - if (cursor_p != NULL) { - pdu_info_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - } - } - - /* Handle vrR if it is made of incomplete PDU Segments */ - if ((cursor_p != NULL) && (pdu_info_p->sn == rlc_pP->vr_r)) { - pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); - next_waited_so = 0; -//Assertion(eNB)_PRAN_DesignDocument_annex No.786 - if(pdu_cursor_mgnt_p->all_segments_received != 0) - { - LOG_E(RLC, "AM Rx Check Reassembly vr=%d should be partly received SNHead=%d LCID=%d\n", - rlc_pP->vr_r,sn_ref,rlc_pP->channel_id); - return false; - } -/* - AssertFatal(pdu_cursor_mgnt_p->all_segments_received == 0,"AM Rx Check Reassembly vr=%d should be partly received SNHead=%d LCID=%d\n", - rlc_pP->vr_r,sn_ref,rlc_pP->channel_id); -*/ - while ((cursor_p != NULL) && (pdu_info_p->sn == rlc_pP->vr_r) && (pdu_info_p->so == next_waited_so)) { - if (pdu_cursor_mgnt_p->segment_reassembled == RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_NO) { - pdu_cursor_mgnt_p->segment_reassembled = RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_PENDING; - } - next_waited_so += pdu_info_p->payload_size; - cursor_p = cursor_p->next; - if (cursor_p != NULL) { - pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); - pdu_info_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - } - } - } - } /* end sn_ref != rlc_pP->vr_r */ - else { - /* case vrR = partially received */ - - pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); - next_waited_so = 0; -//Assertion(eNB)_PRAN_DesignDocument_annex No.787 - if(pdu_cursor_mgnt_p->all_segments_received != 0) - { - LOG_E(RLC, "AM Rx Check Reassembly SNHead=vr=%d should be partly received LCID=%d\n", - rlc_pP->vr_r,rlc_pP->channel_id); - return false; - } -/* - AssertFatal(pdu_cursor_mgnt_p->all_segments_received == 0,"AM Rx Check Reassembly SNHead=vr=%d should be partly received LCID=%d\n", - rlc_pP->vr_r,rlc_pP->channel_id); -*/ - while ((cursor_p != NULL) && (pdu_info_p->sn == rlc_pP->vr_r) && (pdu_info_p->so == next_waited_so)) { - if (pdu_cursor_mgnt_p->segment_reassembled == RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_NO) { - pdu_cursor_mgnt_p->segment_reassembled = RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_PENDING; - reassemble = true; - } - next_waited_so += pdu_info_p->payload_size; - cursor_p = cursor_p->next; - if (cursor_p != NULL) { - pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); - pdu_info_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - } - } - } /*end sn_ref == rlc_pP->vr_r */ - } - return reassemble; -} - -mem_block_t * create_new_segment_from_pdu( - mem_block_t* const tb_pP, - uint16_t so_offset, /* offset from the data part of the PDU to copy */ - sdu_size_t data_length_to_copy) -{ - rlc_am_pdu_info_t* pdu_rx_info_p = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; - rlc_am_pdu_info_t* pdu_new_segment_info_p = NULL; - mem_block_t * new_segment_p = NULL; - int16_t new_li_list[RLC_AM_MAX_SDU_IN_PDU]; - int16_t header_size = 0; - uint8_t num_li = 0; - bool fi_start, fi_end, lsf; - - /* Init some PDU Segment header fixed parameters */ - fi_start = !((pdu_rx_info_p->fi & 0x2) >> 1); - fi_end = !(pdu_rx_info_p->fi & 0x1); - lsf = ((pdu_rx_info_p->lsf == 1) || (pdu_rx_info_p->rf == 0)); - - /* Handle NO Li case fist */ - if (pdu_rx_info_p->num_li == 0) { - - header_size = RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE; - - if (so_offset) { - fi_start = false; - } - if (so_offset + data_length_to_copy != pdu_rx_info_p->payload_size) { - fi_end = false; - lsf = false; - } - } // end no LI in original segment - else { - - uint8_t li_index = 0; - uint16_t li_sum = 0; - num_li = pdu_rx_info_p->num_li; - - /* set LSF to false if we know that end of the original segment will not be copied */ - if (so_offset + data_length_to_copy != pdu_rx_info_p->payload_size) { - lsf = false; - } - - /* catch the first LI containing so_offset */ - while ((li_index < pdu_rx_info_p->num_li) && (li_sum + pdu_rx_info_p->li_list[li_index] <= so_offset)) { - li_sum += pdu_rx_info_p->li_list[li_index]; - num_li --; - li_index ++; - } - - /* set FI start if so_offset = LI sum and at least one LI have been read */ - if ((li_index) && (so_offset == li_sum)) { - fi_start = TRUE; - } - - /* Fill LI until the end */ - if (num_li) { - sdu_size_t remaining_size = data_length_to_copy; - uint8_t j = 0; - new_li_list[0] = li_sum + pdu_rx_info_p->li_list[li_index] - so_offset; - if (data_length_to_copy <= new_li_list[0]) { - num_li = 0; - } - else { - remaining_size -= new_li_list[0]; - j++; - li_index ++; - while ((li_index < pdu_rx_info_p->num_li) && (remaining_size >= pdu_rx_info_p->li_list[li_index])) { - remaining_size -= pdu_rx_info_p->li_list[li_index]; - new_li_list[j] = pdu_rx_info_p->li_list[li_index]; - j++; - li_index ++; - } - - /* update number of LI in the segment */ - num_li = j; - /* set FI End if remaining size = 0 */ - if (remaining_size == 0) { - fi_end = true; - } - } - } - - /* compute header size */ - header_size = RLC_AM_PDU_SEGMENT_HEADER_SIZE(num_li); - - } // end LIs in original segment - - /* Allocate new buffer */ - new_segment_p = get_free_mem_block(sizeof (mac_rlc_max_rx_header_size_t) + header_size + data_length_to_copy, __func__); - - /* Fill PDU Segment Infos and Header */ - if (new_segment_p != NULL) { - pdu_new_segment_info_p = &((rlc_am_rx_pdu_management_t*)(new_segment_p->data))->pdu_info; - rlc_am_rx_pdu_management_t * pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (new_segment_p->data); - uint8_t *pdu_segment_header_p = (uint8_t *)&(new_segment_p->data[sizeof (mac_rlc_max_rx_header_size_t)]); - - pdu_cursor_mgnt_p->segment_reassembled = RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_NO; //to be updated after if SN = vrR - - pdu_new_segment_info_p->d_c = pdu_rx_info_p->d_c; - pdu_new_segment_info_p->sn = pdu_rx_info_p->sn; - pdu_new_segment_info_p->p = pdu_rx_info_p->p; - pdu_new_segment_info_p->rf = 1; - pdu_new_segment_info_p->fi = (((fi_start ? 0: 1) << 1) | (fi_end ? 0: 1)); - pdu_new_segment_info_p->num_li = num_li; - pdu_new_segment_info_p->e = (num_li ? 1: 0); - pdu_new_segment_info_p->lsf = (lsf ? 1: 0); - pdu_new_segment_info_p->so = pdu_rx_info_p->so + so_offset; - pdu_new_segment_info_p->payload = pdu_segment_header_p + header_size; - pdu_new_segment_info_p->header_size = header_size; - pdu_new_segment_info_p->payload_size = data_length_to_copy; - pdu_new_segment_info_p->hidden_size = data_length_to_copy; - for (int i=0; i < num_li; i++) { - pdu_new_segment_info_p->li_list[i] = new_li_list[i]; - pdu_new_segment_info_p->hidden_size -= new_li_list[i]; - } - - /* Fill Header part in the buffer */ - /* Content is supposed to be init with 0 so with FIStart=FIEnd=true */ - /* copy first two bytes from original: D/C + RF + FI + E+ SN*/ - memset(pdu_segment_header_p, 0, header_size); - RLC_AM_PDU_SET_D_C(*pdu_segment_header_p); - RLC_AM_PDU_SET_RF(*pdu_segment_header_p); - if (pdu_new_segment_info_p->p) { - RLC_AM_PDU_SET_POLL(*pdu_segment_header_p); - } - /* Change FI */ - if (!fi_start) - { - // Set to not starting - (*pdu_segment_header_p) |= (1 << (RLC_AM_PDU_FI_OFFSET + 1)); - - } - if (!fi_end) - { - // Set to not starting - (*pdu_segment_header_p) |= (1 << (RLC_AM_PDU_FI_OFFSET)); - - } - /* E */ - if (pdu_new_segment_info_p->e) { - RLC_AM_PDU_SET_E(*pdu_segment_header_p); - } - /* SN */ - (*pdu_segment_header_p) |= ((pdu_new_segment_info_p->sn >> 8) & 0x3); - *(pdu_segment_header_p + 1) = (pdu_new_segment_info_p->sn & 0xFF); - - pdu_segment_header_p += 2; - - /* Last Segment Flag (LSF) */ - if (lsf) - { - RLC_AM_PDU_SET_LSF(*pdu_segment_header_p); - } - /* Store SO bytes */ - * (pdu_segment_header_p ) |= ((pdu_new_segment_info_p->so >> 8) & 0x7F); - * (pdu_segment_header_p + 1) = pdu_new_segment_info_p->so & 0xFF; - - if (num_li) { - uint16_t index = 0; - uint16_t temp = 0; - uint8_t li_bit_offset = 4; /* toggle between 0 and 4 */ - uint8_t li_jump_offset = 1; /* toggle between 1 and 2 */ - - /* loop on nb of LIs */ - pdu_segment_header_p += 2; - - while (index < num_li) - { - /* Set E bit for next LI if present */ - if (index < num_li - 1) - RLC_SET_BIT(temp,li_bit_offset + RLC_AM_LI_BITS); - /* Set LI */ - RLC_AM_PDU_SET_LI(temp,new_li_list[index],li_bit_offset); - *pdu_segment_header_p = temp >> 8; - *(pdu_segment_header_p + 1) = temp & 0xFF; - pdu_segment_header_p += li_jump_offset; - li_bit_offset ^= 0x4; - li_jump_offset ^= 0x3; - - temp = ((*pdu_segment_header_p) << 8) | (*(pdu_segment_header_p + 1)); - index ++; - } - } - - /* copy data part */ - /* Fill mem_block contexts */ - ((struct mac_tb_ind *) (new_segment_p->data))->first_bit = 0; - ((struct mac_tb_ind *) (new_segment_p->data))->data_ptr = (uint8_t*)&new_segment_p->data[sizeof (mac_rlc_max_rx_header_size_t)]; - ((struct mac_tb_ind *) (new_segment_p->data))->size = data_length_to_copy + header_size; - memcpy(pdu_new_segment_info_p->payload,pdu_rx_info_p->payload + so_offset,data_length_to_copy); - } - - return new_segment_p; -} - -rlc_am_rx_pdu_status_t rlc_am_rx_list_handle_pdu_segment( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP, - mem_block_t* const tb_pP) -{ - rlc_am_pdu_info_t* pdu_rx_info_p = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; - rlc_am_pdu_info_t* pdu_info_cursor_p = NULL; - rlc_am_pdu_info_t* pdu_info_previous_cursor_p = NULL; - mem_block_t* cursor_p = rlc_pP->receiver_buffer.head; - mem_block_t* previous_cursor_p = NULL; - mem_block_t* next_cursor_p = NULL; - uint16_t so_start_min = 0; - uint16_t so_end = 0; - uint16_t so_start_segment = pdu_rx_info_p->so; - uint16_t so_end_segment = pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1; - - /*****************************************************/ - // 1) Find previous cursor to the PDU to insert - /*****************************************************/ -//Assertion(eNB)_PRAN_DesignDocument_annex No.791 - if(cursor_p == NULL) - { - LOG_E(RLC, "AM Rx PDU Error, received buffer empty LcID=%d\n",rlc_pP->channel_id); - return RLC_AM_DATA_PDU_STATUS_HEADER_ERROR; - } -/* - AssertFatal(cursor_p != NULL,"AM Rx PDU Error, received buffer empty LcID=%d\n",rlc_pP->channel_id); -*/ - do { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - - // Stop if Cursor SN >= Received SN - if (RLC_AM_DIFF_SN(pdu_info_cursor_p->sn,rlc_pP->vr_r) >= RLC_AM_DIFF_SN(pdu_rx_info_p->sn,rlc_pP->vr_r)) { - break; - } - - previous_cursor_p = cursor_p; - pdu_info_previous_cursor_p = pdu_info_cursor_p; - cursor_p = cursor_p->next; - } while (cursor_p != NULL); - - /*****************************************************/ - // 2) Store the received Segment - /*****************************************************/ - // First case : cursor_p is NULL or its SN is different from the received one, it means the SN is received for the first time - // Insert PDU after previous_cursor_p - if ((cursor_p == NULL) || (pdu_info_cursor_p->sn != pdu_rx_info_p->sn)) { - if (previous_cursor_p != NULL) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SEGMENT SN=%d] PDU SEGMENT INSERTED AFTER PDU SN=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_rx_info_p->sn, - pdu_info_previous_cursor_p->sn); - list2_insert_after_element(tb_pP, previous_cursor_p, &rlc_pP->receiver_buffer); - } - else { /* SN of head of Rx PDU list is higher than received PDU SN */ - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SEGMENT SN=%d] PDU SEGMENT INSERTED BEFORE PDU SN=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_rx_info_p->sn, - pdu_info_cursor_p->sn); - list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); - } - - return RLC_AM_DATA_PDU_STATUS_OK; - } - - /********************************************/ - /* Now handle case cursor->sn = received SN */ - /********************************************/ - - rlc_am_rx_pdu_management_t * pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); - - // Filter out SN duplicate - if (pdu_cursor_mgnt_p->all_segments_received) { - return RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE; - } - - // Try to catch a segment duplicate - next_cursor_p = cursor_p; - while ((next_cursor_p != NULL) && (pdu_info_cursor_p->sn == pdu_rx_info_p->sn)) { - if ((so_start_segment >= pdu_info_cursor_p->so) && (so_end_segment <= pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size - 1)) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SEGMENT] DISCARD : DUPLICATE SEGMENT SN=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_rx_info_p->sn); - return RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE; - } - next_cursor_p = next_cursor_p->next; - if (next_cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(next_cursor_p->data))->pdu_info; - } - } - - // Reset pdu_info_cursor_p because of the loop before - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - - // Try to Handle the most likely cases first - if (pdu_info_cursor_p->so == 0) { - - /* Loop on stored segments and find the stored segment containing received SOStart */ - previous_cursor_p = cursor_p; - pdu_info_previous_cursor_p = pdu_info_cursor_p; - while ((cursor_p != NULL) && (pdu_info_cursor_p->sn == pdu_rx_info_p->sn) - && ((pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size) <= so_start_segment)) { - previous_cursor_p = cursor_p; - pdu_info_previous_cursor_p = pdu_info_cursor_p; - cursor_p = cursor_p->next; - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - } - } - - // Most likely case : no duplicate, the segment is put after all stored segments which are contiguous - if ((cursor_p == NULL) || (pdu_info_cursor_p->sn != pdu_rx_info_p->sn) || (pdu_info_cursor_p->so > so_end_segment)) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SEGMENT SN=%d SOSTART=%d] PDU SEGMENT INSERTED AFTER PDU SEGMENT WITH SOEND=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_rx_info_p->sn,so_start_segment, - pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size - 1); - - list2_insert_after_element(tb_pP, previous_cursor_p, &rlc_pP->receiver_buffer); - return RLC_AM_DATA_PDU_STATUS_OK; - } - - // Duplicate case : Resume contiguous scan and update previous_cursor_p - so_start_min = pdu_info_previous_cursor_p->so; - so_end = so_start_min + pdu_info_previous_cursor_p->payload_size; - cursor_p = previous_cursor_p->next; - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - } - while ((cursor_p != NULL) && (pdu_info_cursor_p->sn == pdu_rx_info_p->sn) - && (pdu_info_cursor_p->so == so_end)) { - previous_cursor_p = cursor_p; - pdu_info_previous_cursor_p = pdu_info_cursor_p; - so_end += pdu_info_cursor_p->payload_size; - cursor_p = cursor_p->next; - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - } - } - - /* Now discard the PDU segment if it is within so_start_min and so_end */ - if ((so_start_min <= so_start_segment) && (so_end_segment <= so_end - 1)) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SEGMENT] DISCARD : DUPLICATE SEGMENT SN=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_rx_info_p->sn); - return RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE; - } - - // Discard potential embedded segments in the received PDU segment - // The first one is discontigous - next_cursor_p = cursor_p; - while ((next_cursor_p != NULL) && (pdu_info_cursor_p->sn == pdu_rx_info_p->sn) && - (so_end_segment >= pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size - 1)) { - /* Discard the segment */ - cursor_p = next_cursor_p; - next_cursor_p = next_cursor_p->next; - list2_remove_element (cursor_p, &rlc_pP->receiver_buffer); - free_mem_block(cursor_p, __func__); - - if (next_cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(next_cursor_p->data))->pdu_info; - } - } - cursor_p = next_cursor_p; - - //Remove duplicate at the begining - if (so_start_segment < pdu_info_previous_cursor_p->so) { - so_start_segment = pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size; - } - else if (so_start_segment < pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size){ - so_start_segment += (pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size - so_start_segment); - } - - // Now remove duplicate at the end, only valid if cursor_p SN has the same received SN - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(next_cursor_p->data))->pdu_info; - - if ((pdu_info_cursor_p->sn == pdu_rx_info_p->sn) && (so_end_segment >= pdu_info_cursor_p->so)) { - so_end_segment = pdu_info_cursor_p->so - 1; - } - } - -//Assertion(eNB)_PRAN_DesignDocument_annex No.792 - if((so_start_segment > so_end_segment) || (pdu_rx_info_p->so > so_start_segment) || - (so_end_segment > pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1)) - { - LOG_E(RLC, " AM RX PDU Segment Duplicate elimination error FirstSO=0 OldSOStart=%d OldSOEnd=%d newSOStart=%d newSOEnd =%d SN=%d\n", - pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_start_segment,so_end_segment,pdu_rx_info_p->sn); - return RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE; - } -/* - AssertFatal((so_start_segment <= so_end_segment) && (pdu_rx_info_p->so <= so_start_segment) && - (so_end_segment <= pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1), - " AM RX PDU Segment Duplicate elimination error FirstSO=0 OldSOStart=%d OldSOEnd=%d newSOStart=%d newSOEnd =%d SN=%d\n", - pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_start_segment,so_end_segment,pdu_rx_info_p->sn); -*/ - } // end pdu_info_cursor_p->so == 0 - else { - // Handle most likely case : PDU Segment without duplicate is inserted before first stored PDU segment - if (so_end_segment < pdu_info_cursor_p->so) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SEGMENT SN=%d SOSTART=%d SOEND=%d] PDU SEGMENT INSERTED BEFORE PDU SEGMENT WITH SOSTART=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_rx_info_p->sn,so_start_segment,so_end_segment, - pdu_info_cursor_p->so); - - list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); - return RLC_AM_DATA_PDU_STATUS_OK; - } - - // Handle duplicate case - if (so_start_segment < pdu_info_cursor_p->so) { - // First Case : only duplicate at the end - // Scan for embedded segments to be discarded - next_cursor_p = cursor_p; - while ((next_cursor_p != NULL) && (pdu_info_cursor_p->sn == pdu_rx_info_p->sn) && - (so_end_segment >= pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size - 1)) { - /* Discard the segment */ - cursor_p = next_cursor_p; - next_cursor_p = next_cursor_p->next; - list2_remove_element (cursor_p, &rlc_pP->receiver_buffer); - free_mem_block(cursor_p, __func__); - - if (next_cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(next_cursor_p->data))->pdu_info; - } - } - cursor_p = next_cursor_p; - - // Now remove duplicate at the end, only valid if cursor_p SN has the same received SN - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(next_cursor_p->data))->pdu_info; - - if ((pdu_info_cursor_p->sn == pdu_rx_info_p->sn) && (so_end_segment >= pdu_info_cursor_p->so)) { - so_end_segment = pdu_info_cursor_p->so - 1; - } - } -//Assertion(eNB)_PRAN_DesignDocument_annex No.793 - if((so_start_segment > so_end_segment) || - (so_end_segment > pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1)) - { - LOG_E(RLC, " AM RX PDU Segment Duplicate elimination at the end error FirstSO!=0 SOStart=%d OldSOEnd=%d newSOEnd =%d SN=%d\n", - pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_end_segment,pdu_rx_info_p->sn); - return RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE; - } -/* - AssertFatal((so_start_segment <= so_end_segment) && - (so_end_segment <= pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1), - " AM RX PDU Segment Duplicate elimination at the end error FirstSO!=0 SOStart=%d OldSOEnd=%d newSOEnd =%d SN=%d\n", - pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_end_segment,pdu_rx_info_p->sn); -*/ - } - else { - // Second Case: Duplicate at the begining and potentially at the end - /* Loop on stored segments and find the stored segment containing received SOStart */ - - previous_cursor_p = cursor_p; - pdu_info_previous_cursor_p = pdu_info_cursor_p; - while ((cursor_p != NULL) && (pdu_info_cursor_p->sn == pdu_rx_info_p->sn) - && ((pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size) <= so_start_segment)) { - previous_cursor_p = cursor_p; - pdu_info_previous_cursor_p = pdu_info_cursor_p; - cursor_p = cursor_p->next; - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - } - } - - // Most likely case : no duplicate, the segment is put after all stored segments which are contiguous - if ((cursor_p == NULL) || (pdu_info_cursor_p->sn != pdu_rx_info_p->sn) || (pdu_info_cursor_p->so > so_end_segment)) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SEGMENT SN=%d SOSTART=%d] PDU SEGMENT INSERTED AFTER PDU SEGMENT WITH SOEND=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_rx_info_p->sn,so_start_segment, - pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size - 1); - - list2_insert_after_element(tb_pP, previous_cursor_p, &rlc_pP->receiver_buffer); - return RLC_AM_DATA_PDU_STATUS_OK; - } - - // Now look for contiguous segments to check whether the received segment is not fully duplicate - so_start_min = pdu_info_previous_cursor_p->so; - so_end = so_start_min + pdu_info_previous_cursor_p->payload_size; - cursor_p = previous_cursor_p->next; - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - } - while ((cursor_p != NULL) && (pdu_info_cursor_p->sn == pdu_rx_info_p->sn) - && (pdu_info_cursor_p->so == so_end)) { - previous_cursor_p = cursor_p; - pdu_info_previous_cursor_p = pdu_info_cursor_p; - so_end += pdu_info_cursor_p->payload_size; - cursor_p = cursor_p->next; - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - } - } - - /* Now discard the PDU segment if it is within so_start_min and so_end */ - if ((so_start_min <= so_start_segment) && (so_end_segment < so_end)) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SEGMENT] DISCARD : DUPLICATE SEGMENT SN=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_rx_info_p->sn); - return RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE; - } - - //Remove duplicate at the begining - if (so_start_segment < pdu_info_previous_cursor_p->so) { - so_start_segment = pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size; - } - else if (so_start_segment < pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size){ - so_start_segment += (pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size - so_start_segment); - } - - - // Now Scan for embedded segments to be discarded - next_cursor_p = cursor_p; - while ((next_cursor_p != NULL) && (pdu_info_cursor_p->sn == pdu_rx_info_p->sn) && - (so_end_segment >= pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size - 1)) { - /* Discard the segment */ - cursor_p = next_cursor_p; - next_cursor_p = next_cursor_p->next; - list2_remove_element (cursor_p, &rlc_pP->receiver_buffer); - free_mem_block(cursor_p, __func__); - - if (next_cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(next_cursor_p->data))->pdu_info; - } - } - cursor_p = next_cursor_p; - - // Now remove duplicate at the end, only valid if cursor_p SN has the same received SN - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(next_cursor_p->data))->pdu_info; - - if ((pdu_info_cursor_p->sn == pdu_rx_info_p->sn) && (so_end_segment >= pdu_info_cursor_p->so)) { - so_end_segment = pdu_info_cursor_p->so - 1; - } - } -//Assertion(eNB)_PRAN_DesignDocument_annex No.794 - if((so_start_segment > so_end_segment) || (pdu_rx_info_p->so > so_start_segment) || - (so_end_segment > pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1)) - { - LOG_E(RLC, " AM RX PDU Segment Duplicate elimination error FirstSO!=0 OldSOStart=%d OldSOEnd=%d newSOStart=%d newSOEnd =%d SN=%d\n", - pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_start_segment,so_end_segment,pdu_rx_info_p->sn); - return RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE; - } -/* - AssertFatal((so_start_segment <= so_end_segment) && (pdu_rx_info_p->so <= so_start_segment) && - (so_end_segment <= pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1), - " AM RX PDU Segment Duplicate elimination error FirstSO!=0 OldSOStart=%d OldSOEnd=%d newSOStart=%d newSOEnd =%d SN=%d\n", - pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_start_segment,so_end_segment,pdu_rx_info_p->sn); -*/ - } - - } // end pdu_info_cursor_p->so != 0 - - - /* Last step : duplicate bytes had been removed, build a new PDU segment */ -//Assertion(eNB)_PRAN_DesignDocument_annex No.795 - if((pdu_rx_info_p->so == so_start_segment) && (so_end_segment == pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1)) - { - LOG_E(RLC, " AM RX PDU Segment Duplicate elimination error FirstSO!=0 OldSOStart=%d OldSOEnd=%d newSOStart=%d newSOEnd =%d SN=%d\n", - pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_start_segment,so_end_segment,pdu_rx_info_p->sn); - return RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE; - } -/* - AssertFatal((pdu_rx_info_p->so != so_start_segment) || (so_end_segment != pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1), - " AM RX PDU Segment Duplicate elimination error FirstSO!=0 OldSOStart=%d OldSOEnd=%d newSOStart=%d newSOEnd =%d SN=%d\n", - pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_start_segment,so_end_segment,pdu_rx_info_p->sn); -*/ - 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_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) { - list2_insert_after_element(trunc_segment, previous_cursor_p, &rlc_pP->receiver_buffer); - } - else { - list2_insert_before_element(trunc_segment, rlc_pP->receiver_buffer.head, &rlc_pP->receiver_buffer); - } - - /* Free original PDU Segment */ - free_mem_block(tb_pP, __func__); - - return RLC_AM_DATA_PDU_STATUS_OK; - } - else { - return RLC_AM_DATA_PDU_STATUS_BUFFER_FULL; - } - -} - -rlc_am_rx_pdu_status_t rlc_am_rx_list_handle_pdu( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP, - mem_block_t* const tb_pP) -{ - rlc_am_pdu_info_t* pdu_rx_info_p = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; - rlc_am_pdu_info_t* pdu_info_cursor_p = NULL; - mem_block_t* cursor_p = rlc_pP->receiver_buffer.head; - mem_block_t* previous_cursor_p = NULL; - rlc_am_rx_pdu_status_t pdu_status = RLC_AM_DATA_PDU_STATUS_OK; - // it is assumed this pdu is in rx window - - - /*****************************************************/ - // 1) Find previous cursor to the PDU to insert - /*****************************************************/ -//Assertion(eNB)_PRAN_DesignDocument_annex No.788 - if(cursor_p == NULL) - { - LOG_E(RLC, "AM Rx PDU Error, received buffer empty LcID=%d\n",rlc_pP->channel_id); - return RLC_AM_DATA_PDU_STATUS_HEADER_ERROR; - } -/* - AssertFatal(cursor_p != NULL,"AM Rx PDU Error, received buffer empty LcID=%d\n",rlc_pP->channel_id); -*/ - do { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - - // Stop if Cursor SN >= Received SN - if (RLC_AM_DIFF_SN(pdu_info_cursor_p->sn,rlc_pP->vr_r) >= RLC_AM_DIFF_SN(pdu_rx_info_p->sn,rlc_pP->vr_r)) { - break; - } - - previous_cursor_p = cursor_p; - cursor_p = cursor_p->next; - } while (cursor_p != NULL); - - /*****************************************************/ - // 2) Insert PDU by removing byte duplicate if required - /*****************************************************/ - // First case : cursor_p is NULL or SN are different, it means the SN is received for the first time - // Insert PDU after previous_cursor_p - if ((cursor_p == NULL) || (pdu_info_cursor_p->sn != pdu_rx_info_p->sn)) { - if (previous_cursor_p != NULL) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SN=%d] PDU INSERTED AFTER PDU SN=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_rx_info_p->sn, - ((rlc_am_rx_pdu_management_t*)(previous_cursor_p->data))->pdu_info.sn); - list2_insert_after_element(tb_pP, previous_cursor_p, &rlc_pP->receiver_buffer); - } - else { /* SN of head of Rx PDU list is higher than received PDU SN */ - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SN=%d] PDU INSERTED BEFORE PDU SN=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_rx_info_p->sn, - pdu_info_cursor_p->sn); - list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); - } - - return pdu_status; - } - - // Filter out SN duplicate - // SN of received PDU has already data stored - rlc_am_rx_pdu_management_t * pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); - - if (pdu_cursor_mgnt_p->all_segments_received) { - return RLC_AM_DATA_PDU_STATUS_SN_DUPLICATE; - } - - /* check if the received PDU is equal to vrR */ - if ((pdu_rx_info_p->sn != rlc_pP->vr_r) || (pdu_info_cursor_p->so != 0)) { - /* The full received PDU can replace the allready received PDU Segments. */ - /* clean them and append this PDU */ - mem_block_t* cursor_next_p = cursor_p; - while (cursor_next_p) { - cursor_p = cursor_next_p; - cursor_next_p = cursor_next_p->next; - list2_remove_element (cursor_p, &rlc_pP->receiver_buffer); - free_mem_block(cursor_p, __func__); - if (cursor_next_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_next_p->data))->pdu_info; - if (pdu_info_cursor_p->sn != pdu_rx_info_p->sn) { - break; - } - } - } - - 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); - - 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 { - /* First update cursor until discontinuity */ - previous_cursor_p = cursor_p; -//Assertion(eNB)_PRAN_DesignDocument_annex No.789 - if(pdu_info_cursor_p->rf == 0) - { - LOG_E(RLC, "AM Rx PDU Error, stored SN=%d should be a PDU segment\n",pdu_info_cursor_p->sn); - return RLC_AM_DATA_PDU_STATUS_HEADER_ERROR; - } -/* - AssertFatal(pdu_info_cursor_p->rf != 0,"AM Rx PDU Error, stored SN=%d should be a PDU segment\n",pdu_info_cursor_p->sn); -*/ -//Assertion(eNB)_PRAN_DesignDocument_annex No.790 - if(((rlc_am_rx_pdu_management_t *) (cursor_p->data))->all_segments_received != 0) - { - LOG_E(RLC, "AM Rx PDU Error, stored SN=%d already fully received\n",pdu_info_cursor_p->sn); - return RLC_AM_DATA_PDU_STATUS_SN_DUPLICATE; - } -/* - AssertFatal(((rlc_am_rx_pdu_management_t *) (cursor_p->data))->all_segments_received == 0, - "AM Rx PDU Error, stored SN=%d already fully received\n",pdu_info_cursor_p->sn); -*/ - sdu_size_t next_waited_so = 0; - while ((cursor_p != NULL) && (pdu_info_cursor_p->sn == pdu_rx_info_p->sn) && (pdu_info_cursor_p->so == next_waited_so)) { - next_waited_so += pdu_info_cursor_p->payload_size; - previous_cursor_p = cursor_p; - cursor_p = cursor_p->next; - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - } - } - /* Create a new PDU segment by removing first next_waited_so bytes */ - 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) { - /* Insert PDU Segment */ - list2_insert_after_element(trunc_pdu, previous_cursor_p, &rlc_pP->receiver_buffer); - - 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 */ - if ((cursor_p != NULL) && (pdu_info_cursor_p->sn == pdu_rx_info_p->sn)) { - mem_block_t* cursor_next_p = cursor_p; - while (cursor_next_p) { - cursor_p = cursor_next_p; - cursor_next_p = cursor_next_p->next; - list2_remove_element (cursor_p, &rlc_pP->receiver_buffer); - free_mem_block(cursor_p, __func__); - if (cursor_next_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_next_p->data))->pdu_info; - if (pdu_info_cursor_p->sn != pdu_rx_info_p->sn) { - break; - } - } - } - } - - /* Free original PDU */ - free_mem_block(tb_pP, __func__); - - return pdu_status; - } - else { - return RLC_AM_DATA_PDU_STATUS_BUFFER_FULL; - } - } -} - -// returns 0 if success -// returns neg value if failure -//----------------------------------------------------------------------------- -rlc_am_rx_pdu_status_t -rlc_am_rx_list_check_duplicate_insert_pdu( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP, - mem_block_t* const tb_pP) -{ - rlc_am_pdu_info_t* pdu_rx_info_p = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; - mem_block_t* cursor_p = NULL; - cursor_p = rlc_pP->receiver_buffer.head; - rlc_am_rx_pdu_status_t pdu_status = RLC_AM_DATA_PDU_STATUS_OK; - // it is assumed this pdu is in rx window - - /* Init Reassembly status */ - ((rlc_am_rx_pdu_management_t*)(tb_pP->data))->segment_reassembled = RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_NO; - - if (cursor_p == NULL) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[INSERT PDU] LINE %d RX PDU SN %04d (only inserted)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - __LINE__, - pdu_rx_info_p->sn); - list2_add_head(tb_pP, &rlc_pP->receiver_buffer); - return pdu_status; - } - - - if (pdu_rx_info_p->rf == 0) { // Case normal PDU received - pdu_status = rlc_am_rx_list_handle_pdu(ctxt_pP,rlc_pP,tb_pP); - } - else { - pdu_status = rlc_am_rx_list_handle_pdu_segment(ctxt_pP,rlc_pP,tb_pP); - } - - return pdu_status; -} - -//----------------------------------------------------------------------------- -void -rlc_am_rx_check_all_byte_segments( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP, - mem_block_t* const tb_pP) -{ - rlc_am_pdu_info_t *pdu_info_p = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; - mem_block_t *cursor_p = NULL; - mem_block_t *first_cursor_p = NULL; - rlc_usn_t sn = pdu_info_p->sn; - sdu_size_t next_waited_so; - sdu_size_t last_end_so; - - //msg("rlc_am_rx_check_all_byte_segments(%d) @0\n",sn); - if (pdu_info_p->rf == 0) { - ((rlc_am_rx_pdu_management_t*)(tb_pP->data))->all_segments_received = 1; - return; - } - - // for re-segmented AMD PDUS - cursor_p = tb_pP; - //list2_init(&list, NULL); - //list2_add_head(cursor_p, &list); - //msg("rlc_am_rx_check_all_byte_segments(%d) @1\n",sn); - - // get all previous PDU with same SN - while (cursor_p->previous != NULL) { - if (((rlc_am_rx_pdu_management_t*)(cursor_p->previous->data))->pdu_info.sn == sn) { - //list2_add_head(cursor_p->previous, &list); - cursor_p = cursor_p->previous; - //msg("rlc_am_rx_check_all_byte_segments(%d) @2\n",sn); - } else { - break; - } - } - - // in case all first segments up to tb_pP are in list - // the so field of the first PDU should be 0 - //cursor_p = list.head; - //we start from the first stored PDU segment of this SN - if(cursor_p->data == NULL){ - return; - } - pdu_info_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - - // if the first segment does not have SO = 0 then no need to continue - if (pdu_info_p->so != 0) { - return; - } - - //msg("rlc_am_rx_check_all_byte_segments(%d) @3\n",sn); - next_waited_so = pdu_info_p->payload_size; - first_cursor_p = cursor_p; - // then check if all segments are contiguous - last_end_so = pdu_info_p->payload_size; - - while (cursor_p->next != NULL) { - //msg("rlc_am_rx_check_all_byte_segments(%d) @4\n",sn); - cursor_p = cursor_p->next; - if(cursor_p->data == NULL){ - return; - } - pdu_info_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - - if (pdu_info_p->sn == sn) { - // extra check normally not necessary - if ( - !(pdu_info_p->rf == 1) || - !(pdu_info_p->so <= last_end_so) - ) { - //msg("rlc_am_rx_check_all_byte_segments(%d) @5 pdu_info_p->rf %d pdu_info_p->so %d\n",sn, pdu_info_p->rf, pdu_info_p->so); - return; - } else { - if (pdu_info_p->so == next_waited_so) { - next_waited_so = next_waited_so + pdu_info_p->payload_size; - //msg("rlc_am_rx_check_all_byte_segments(%d) @6\n",sn); - } else { // assumed pdu_info_p->so + pdu_info_p->payload_size > next_waited_so - //next_waited_so = (next_waited_so + pdu_info_p->payload_size) - (next_waited_so - pdu_info_p->so); - //msg("rlc_am_rx_check_all_byte_segments(%d) @7\n",sn); - return; - } - - if (pdu_info_p->lsf > 0) { - //msg("rlc_am_rx_check_all_byte_segments(%d) @8\n",sn); - rlc_am_rx_mark_all_segments_received(ctxt_pP, rlc_pP, first_cursor_p); - return; - } - } - - last_end_so = pdu_info_p->so + pdu_info_p->payload_size; - } else { - //msg("rlc_am_rx_check_all_byte_segments(%d) @9\n",sn); - return; - } - } -} -//----------------------------------------------------------------------------- -void -rlc_am_rx_mark_all_segments_received( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP, - mem_block_t* const fisrt_segment_tbP) -{ - rlc_am_pdu_info_t* pdu_info_p = &((rlc_am_rx_pdu_management_t*)(fisrt_segment_tbP->data))->pdu_info; - rlc_am_pdu_info_t* pdu_info_cursor_p = NULL; - mem_block_t* cursor_p = NULL; - rlc_sn_t sn = pdu_info_p->sn; - - cursor_p = fisrt_segment_tbP; - - if (cursor_p) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU] ALL SEGMENTS RECEIVED SN %04d:\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - sn); - - do { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - - if (pdu_info_cursor_p->sn == sn) { - ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->all_segments_received = 1; - } else { - return; - } - - cursor_p = cursor_p->next; - } while (cursor_p != NULL); - } -} -//----------------------------------------------------------------------------- -//#define RLC_AM_DEBUG_REASSEMBLY -void -rlc_am_rx_list_reassemble_rlc_sdus( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP) -{ - mem_block_t* cursor_p = NULL; - rlc_am_rx_pdu_management_t* rlc_am_rx_old_pdu_management = NULL; - rlc_am_pdu_info_t* pdu_info_p = NULL; - - cursor_p = list2_get_head(&rlc_pP->receiver_buffer); - - if (cursor_p == NULL) { - return; - } - - rlc_am_rx_pdu_management_t* rlc_am_rx_pdu_management_p = ((rlc_am_rx_pdu_management_t*)(cursor_p->data)); - pdu_info_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; -#ifdef RLC_AM_DEBUG_REASSEMBLY - rlc_usn_t sn_reass_start = pdu_info_p->sn; -#endif - - /* Specific process for the first SN if all PDU segments had been reassembled but not freed */ - if ((rlc_am_rx_pdu_management_p->all_segments_received > 0) && (pdu_info_p->rf != 0)) { - rlc_sn_t sn = pdu_info_p->sn; - while ((cursor_p != NULL) && (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->segment_reassembled == RLC_AM_RX_PDU_SEGMENT_REASSEMBLED) - && ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.sn == sn) { - cursor_p = list2_remove_head(&rlc_pP->receiver_buffer); - free_mem_block(cursor_p, __func__); - cursor_p = list2_get_head(&rlc_pP->receiver_buffer); - } - - /* Reset Management pointers */ - if (cursor_p != NULL) { - rlc_am_rx_pdu_management_p = ((rlc_am_rx_pdu_management_t*)(cursor_p->data)); - /* Next SN must be the same or SN+1 */ - if (RLC_AM_DIFF_SN(rlc_am_rx_pdu_management_p->pdu_info.sn,sn) > 1) { - return; - } - } - else { - return; - } - } - - do { - if (rlc_am_rx_pdu_management_p->all_segments_received > 0) { - cursor_p = list2_remove_head(&rlc_pP->receiver_buffer); - rlc_am_reassemble_pdu(ctxt_pP, rlc_pP, cursor_p, true); - rlc_am_rx_old_pdu_management = rlc_am_rx_pdu_management_p; - cursor_p = list2_get_head(&rlc_pP->receiver_buffer); - - if (cursor_p == NULL) { -#ifdef RLC_AM_DEBUG_REASSEMBLY - LOG_D(RLC, "RLC AM REASSEMBLY from sn=%d to ALL, vrR=%d vrMS=%d\n", - sn_reass_start,rlc_pP->vr_r,rlc_pP->vr_ms); -#endif - return; - } - - rlc_am_rx_pdu_management_p = ((rlc_am_rx_pdu_management_t*)(cursor_p->data)); - } - else if (rlc_am_rx_pdu_management_p->segment_reassembled == RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_PENDING) { - rlc_am_rx_pdu_management_p->segment_reassembled = RLC_AM_RX_PDU_SEGMENT_REASSEMBLED; - - rlc_am_reassemble_pdu(ctxt_pP, rlc_pP, cursor_p, false); - rlc_am_rx_old_pdu_management = rlc_am_rx_pdu_management_p; - cursor_p = cursor_p->next; - - if (cursor_p == NULL) { -#ifdef RLC_AM_DEBUG_REASSEMBLY - LOG_D(RLC, "RLC AM REASSEMBLY from sn=%d to ALL, Last is Segment, vrR=%d vrMS=%d\n", - sn_reass_start,rlc_pP->vr_r,rlc_pP->vr_ms); -#endif - return; - } - - rlc_am_rx_pdu_management_p = ((rlc_am_rx_pdu_management_t*)(cursor_p->data)); - } - else if (rlc_am_rx_pdu_management_p->segment_reassembled == RLC_AM_RX_PDU_SEGMENT_REASSEMBLED) { - rlc_am_rx_old_pdu_management = rlc_am_rx_pdu_management_p; - cursor_p = cursor_p->next; - - if (cursor_p == NULL) { - return; - } - - rlc_am_rx_pdu_management_p = ((rlc_am_rx_pdu_management_t*)(cursor_p->data)); - } - else { -#if RLC_STOP_ON_LOST_PDU - - if (list2_get_head(&rlc_pP->receiver_buffer) != cursor_p) { - AssertFatal( 0 == 1, - PROTOCOL_RLC_AM_CTXT_FMT" LOST PDU DETECTED\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - } - -#endif -#ifdef RLC_AM_DEBUG_REASSEMBLY - LOG_D(RLC, "RLC AM REASSEMBLY from sn=%d to ALL, vrR=%d vrMS=%d\n", - sn_reass_start,rlc_pP->vr_r,rlc_pP->vr_ms); -#endif - return; - } - - } while (((RLC_AM_DIFF_SN(rlc_am_rx_pdu_management_p->pdu_info.sn,rlc_am_rx_old_pdu_management->pdu_info.sn) < 2) && (rlc_am_rx_old_pdu_management->all_segments_received > 0)) - || ((rlc_am_rx_pdu_management_p->pdu_info.sn == rlc_am_rx_old_pdu_management->pdu_info.sn) && (rlc_am_rx_pdu_management_p->segment_reassembled != RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_NO))); - -#ifdef RLC_AM_DEBUG_REASSEMBLY - mem_block_t* cursor_head_p = list2_get_head(&rlc_pP->receiver_buffer); - if (cursor_head_p == NULL) { - return; - } - - rlc_am_pdu_info_t* pdu_info_head_p = &((rlc_am_rx_pdu_management_t*)(cursor_head_p->data))->pdu_info; - - LOG_D(RLC, "RLC AM REASSEMBLY from sn=%d to sn=%d, next_sn=%d head sn=%d vrR=%d vrMS=%d\n", - sn_reass_start,rlc_am_rx_old_pdu_management->pdu_info.sn,rlc_am_rx_pdu_management_p->pdu_info.sn,pdu_info_head_p->sn,rlc_pP->vr_r,rlc_pP->vr_ms); -#endif - -} -//----------------------------------------------------------------------------- -mem_block_t * -list2_insert_before_element ( - mem_block_t * element_to_insert_pP, - mem_block_t * element_pP, - list2_t * list_pP) -{ - if ((element_to_insert_pP != NULL) && (element_pP != NULL)) { - list_pP->nb_elements = list_pP->nb_elements + 1; - mem_block_t *previous = element_pP->previous; - element_to_insert_pP->previous = previous; - element_to_insert_pP->next = element_pP; - element_pP->previous = element_to_insert_pP; - - if (previous != NULL) { - previous->next = element_to_insert_pP; - } else if (list_pP->head == element_pP) { - list_pP->head = element_to_insert_pP; - } - - return element_to_insert_pP; - } else { - //assert(2==1); - LOG_E(RLC, "list2_insert_before_element error. element_to_insert_pP %p, element_pP %p\n", element_to_insert_pP,element_pP); - return NULL; - } -} -//----------------------------------------------------------------------------- -mem_block_t * -list2_insert_after_element ( - mem_block_t * element_to_insert_pP, - mem_block_t * element_pP, - list2_t * list_pP) -{ - - if ((element_to_insert_pP != NULL) && (element_pP != NULL)) { - list_pP->nb_elements = list_pP->nb_elements + 1; - mem_block_t *next = element_pP->next; - element_to_insert_pP->previous = element_pP; - element_to_insert_pP->next = next; - element_pP->next = element_to_insert_pP; - - if (next != NULL) { - next->previous = element_to_insert_pP; - } else if (list_pP->tail == element_pP) { - list_pP->tail = element_to_insert_pP; - } - - return element_to_insert_pP; - } else { - //assert(2==1); - LOG_E(RLC, "list2_insert_after_element error. element_to_insert_pP %p, element_pP %p\n", element_to_insert_pP,element_pP); - return NULL; - } -} -//----------------------------------------------------------------------------- -void -rlc_am_rx_list_display ( - const rlc_am_entity_t* const rlc_pP, - char* message_pP) -{ - mem_block_t *cursor_p = NULL; - unsigned int loop = 0; - - cursor_p = rlc_pP->receiver_buffer.head; - - if (message_pP) { - LOG_T(RLC, "Display list %s %s VR(R)=%04d:\n", rlc_pP->receiver_buffer.name, message_pP, rlc_pP->vr_r); - } else { - LOG_T(RLC, "Display list %s VR(R)=%04d:\n", rlc_pP->receiver_buffer.name, rlc_pP->vr_r); - } - - if (cursor_p) { - // almost one element - while (cursor_p != NULL) { - //if (((loop % 16) == 0) && (loop > 0)) { - if ((loop % 4) == 0) { - LOG_T(RLC, "\nRX SN:\t"); - } - - if (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.rf) { - if (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.lsf) { - LOG_T(RLC, "%04d (%04d->%04d LSF)\t", - ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.sn, - ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.so, - ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.so + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.payload_size - 1); - } else { - LOG_T(RLC, "%04d (%04d->%04d)\t", - ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.sn, - ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.so, - ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.so + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.payload_size - 1); - } - } else { - LOG_T(RLC, "%04d (%04d NOSEG)\t", - ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.sn, - ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.payload_size); - } - - //if (cursor_p == cursor_p->next) { - // rlc_am_v9_3_0_test_print_trace(); - //} - //assert(cursor_p != cursor_p->next); - if(cursor_p == cursor_p->next) - { - LOG_E(RLC, "rlc_am_rx_list_display error. cursor_p %p, cursor_p->next %p\n", cursor_p, cursor_p->next); - break; - } - cursor_p = cursor_p->next; - loop++; - } - - LOG_T(RLC, "\n"); - } else { - LOG_T(RLC, "\nNO ELEMENTS\n"); - } -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h deleted file mode 100644 index f86b1810cab4c15fb515e90a5228560372f07aef..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_rx_list.h -* \brief This file defines the prototypes of the functions dealing with a RX list data structure supporting re-segmentation. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_internal_rx_list_impl_ RLC AM RX List Reference Implementation -* @ingroup _rlc_am_internal_receiver_impl_ -* @{ -*/ - -#ifndef __RLC_AM_RX_LIST_H__ -# define __RLC_AM_RX_LIST_H__ - -# include "UTIL/MEM/mem_block.h" -//----------------------------------------------------------------------------- -#include "platform_types.h" -#include "common/platform_constants.h" -//#include "PHY/defs.h" - -//----------------------------------------------------------------------------- -/*! \fn rlc_am_rx_pdu_status_t rlc_am_rx_list_check_duplicate_insert_pdu(const protocol_ctxt_t* const ctxt_pP,rlc_am_entity_t* const rlc_pP,mem_block_t* const tb_pP) -* \brief Insert a PDU in the RX buffer after removing byte duplicate (implemented with a list). -* \param[in] ctxt_pP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] tbP A PDU embedded in a mem_block_t. -* \return Zero if the PDU could be inserted in the RX buffer, a negative value if the PDU could not be inserted. -*/ -rlc_am_rx_pdu_status_t rlc_am_rx_list_check_duplicate_insert_pdu(const protocol_ctxt_t* const ctxt_pP,rlc_am_entity_t* const rlc_pP,mem_block_t* const tb_pP); - -/*! \fn signed int rlc_am_rx_list_insert_pdu(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlcP , mem_block_t* const tbP) -* \brief Insert a PDU in the RX buffer (implemented with a list). -* \param[in] ctxt_pP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] tbP A PDU embedded in a mem_block_t. -* \return Zero if the PDU could be inserted in the RX buffer, a negative value if the PDU could not be inserted. -*/ -signed int rlc_am_rx_list_insert_pdu(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlcP, mem_block_t* const tbP); - -/*! \fn bool rlc_am_rx_check_vr_reassemble(const protocol_ctxt_t* const ctxt_pP,const rlc_am_entity_t* const rlc_pP) -* \brief Check if reassembly taking into account potential new vrR value -* \param[in] ctxt_pP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \return true if reassembly must be done, false else -*/ -bool rlc_am_rx_check_vr_reassemble(const protocol_ctxt_t* const ctxt_pP,const rlc_am_entity_t* const rlc_pP); - -/*! \fn void rlc_am_rx_check_all_byte_segments(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlcP, mem_block_t* const tbP) -* \brief Check if all sub-segments of a PDU are received, if yes then call rlc_am_rx_mark_all_segments_received() procedure. -* \param[in] ctxt_pP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] tbP A PDU embedded in a mem_block_t. -*/ -void rlc_am_rx_check_all_byte_segments(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlcP, mem_block_t* const tbP); - -/*! \fn void rlc_am_rx_mark_all_segments_received (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlcP, mem_block_t* const first_segment_tbP) -* \brief Mark all PDUs having the same sequence number as first_segment_tbP with the information that all segments have been received. -* \param[in] ctxt_pP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] first_segment_tbP A PDU embedded in a mem_block_t, it is the first PDU in the RX buffer (list) that have its sequence number. -*/ -void rlc_am_rx_mark_all_segments_received(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlcP, mem_block_t* const first_segment_tbP); - -/*! \fn void rlc_am_rx_list_reassemble_rlc_sdus(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlcP) -* \brief Reassembly all SDUS that it is possible to reassembly by parsing the RX buffer and looking for PDUs having the flag 'all segments received'. -* \param[in] ctxt_pP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -*/ -void rlc_am_rx_list_reassemble_rlc_sdus(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlcP); - -/*! \fn mem_block_t* list2_insert_before_element (mem_block_t * element_to_insertP, mem_block_t * elementP, list2_t * listP) -* \brief Insert a PDU embedded in a mem_block_t in a list at a position before a designated element of the list. -* \param[in] element_to_insertP Element to insert in the list listP, before elementP position. -* \param[in] elementP Element in the list. -* \param[in] listP List where elements are linked. -*/ -mem_block_t* list2_insert_before_element (mem_block_t * element_to_insertP, mem_block_t * elementP, list2_t * listP); - -/*! \fn mem_block_t* list2_insert_after_element (mem_block_t * element_to_insertP, mem_block_t * elementP, list2_t * listP) -* \brief Insert a PDU embedded in a mem_block_t in a list at a position after a designated element of the list. -* \param[in] element_to_insertP Element to insert in the list listP, after elementP position. -* \param[in] elementP Element in the list. -* \param[in] listP List where elements are linked. -*/ -mem_block_t* list2_insert_after_element (mem_block_t * element_to_insertP, mem_block_t * elementP, list2_t * listP); - -/*! \fn void rlc_am_rx_list_display (const rlc_am_entity_t* const rlcP, char* messageP) -* \brief Display the dump of the RX buffer. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] messageP Message to be displayed along with the display of the dump of the RX buffer. -*/ -void rlc_am_rx_list_display (const rlc_am_entity_t* const rlcP, char* messageP); -/** @} */ -#endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c deleted file mode 100644 index 9e7c3338f813eed7e4cd0022da57770d06fa3ab8..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c +++ /dev/null @@ -1,566 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_SEGMENT_C 1 -//----------------------------------------------------------------------------- -#include <assert.h> -//----------------------------------------------------------------------------- -#include "platform_types.h" -//----------------------------------------------------------------------------- -#include "list.h" -#include "rlc_am.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" - -//----------------------------------------------------------------------------- -void rlc_am_pdu_polling(const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - rlc_am_pdu_sn_10_t *const pdu_pP, - const int16_t payload_sizeP, - bool is_new_pdu) -{ - // 5.2.2 Polling - // An AM RLC entity can poll its peer AM RLC entity in order to trigger STATUS reporting at the peer AM RLC entity. - // 5.2.2.1 Transmission of a AMD PDU or AMD PDU segment - // Upon assembly of a new AMD PDU, the transmitting side of an AM RLC entity shall: - // - increment PDU_WITHOUT_POLL by one; - // - increment BYTE_WITHOUT_POLL by every new byte of Data field element that it maps to the Data field of - // the RLC data PDU; - // - if PDU_WITHOUT_POLL >= pollPDU; or - // - if BYTE_WITHOUT_POLL >= pollByte; - // -include a poll in the RLC data PDU as described below. - // Upon assembly of an AMD PDU or AMD PDU segment, the transmitting side of an AM RLC entity shall: - // - if both the transmission buffer and the retransmission buffer becomes empty (excluding transmitted RLC data - // PDU awaiting for acknowledgements) after the transmission of the RLC data PDU; or - // - if no new RLC data PDU can be transmitted after the transmission of the RLC data PDU (e.g. due to window - // stalling); - // - include a poll in the RLC data PDU as described below. - // To include a poll in a RLC data PDU, the transmitting side of an AM RLC entity shall: - // - set the P field of the RLC data PDU to "1"; - // - set PDU_WITHOUT_POLL to 0; - // - set BYTE_WITHOUT_POLL to 0; - // After delivering a RLC data PDU including a poll to lower layer and after incrementing of VT(S) if necessary, the - // transmitting side of an AM RLC entity shall: - // - set POLL_SN to VT(S) – 1; - // - if t-PollRetransmit is not running: - // - start t-PollRetransmit; - // - else: - // - restart t-PollRetransmit; - - if (is_new_pdu) { - if (rlc_pP->poll_pdu != RLC_AM_POLL_PDU_INFINITE) { - rlc_pP->c_pdu_without_poll += 1; - } - - if (rlc_pP->poll_byte != RLC_AM_POLL_BYTE_INFINITE) { - rlc_pP->c_byte_without_poll += payload_sizeP; - } - } - - if ( - ((is_new_pdu) && ((rlc_pP->c_pdu_without_poll >= rlc_pP->poll_pdu) || - (rlc_pP->c_byte_without_poll >= rlc_pP->poll_byte))) || - ((rlc_pP->sdu_buffer_occupancy == 0) && (rlc_pP->retrans_num_bytes_to_retransmit == 0)) || - (rlc_pP->vt_s == rlc_pP->vt_ms) || - (rlc_pP->force_poll == true) - ) { - rlc_pP->force_poll = false; - - if ((is_new_pdu) && (rlc_pP->c_pdu_without_poll >= rlc_pP->poll_pdu)) { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[POLL] SET POLL BECAUSE TX NUM PDU THRESHOLD %d HAS BEEN REACHED\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->poll_pdu); - } - if ((is_new_pdu) && (rlc_pP->c_byte_without_poll >= rlc_pP->poll_byte)) { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[POLL] SET POLL BECAUSE TX NUM BYTES THRESHOLD %d HAS BEEN REACHED\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->poll_byte); - } - if ((rlc_pP->sdu_buffer_occupancy == 0) && (rlc_pP->retrans_num_bytes_to_retransmit == 0)) { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[POLL] SET POLL BECAUSE TX BUFFERS ARE EMPTY\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - } - if (rlc_pP->vt_s == rlc_pP->vt_ms) { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[POLL] SET POLL BECAUSE OF WINDOW STALLING\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - } - - RLC_AM_PDU_SET_POLL(pdu_pP->b1); - rlc_pP->c_pdu_without_poll = 0; - rlc_pP->c_byte_without_poll = 0; - - // vt_s shall have been updated before in case of new transmission - rlc_pP->poll_sn = RLC_AM_PREV_SN(rlc_pP->vt_s); - //optimisation if (!rlc_pP->t_poll_retransmit.running) { - rlc_am_start_timer_poll_retransmit(ctxt_pP, rlc_pP); - //optimisation } else { - //optimisation rlc_pP->t_poll_retransmit.frame_time_out = ctxt_pP->frame + rlc_pP->t_poll_retransmit.time_out; - //optimisation } - } else { - // Need to clear poll bit as it may be a copy(retransmission case) of the original RLC PDU which was containing a poll - RLC_AM_PDU_CLEAR_POLL(pdu_pP->b1); - } -} -//----------------------------------------------------------------------------- -void rlc_am_segment_10 ( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP) -{ - list_t pdus; - sdu_size_t pdu_remaining_size = 0; - sdu_size_t test_pdu_remaining_size = 0; - - sdu_size_t nb_bytes_to_transmit = rlc_pP->nb_bytes_requested_by_mac; - rlc_am_pdu_sn_10_t *pdu_p = NULL; - struct mac_tb_req *pdu_tb_req_p = NULL; - mem_block_t *pdu_mem_p = NULL; - unsigned char *data = NULL; - unsigned char *data_sdu_p = NULL; - rlc_am_e_li_t *e_li_p = NULL; - rlc_am_tx_sdu_management_t *sdu_mngt_p = NULL; - rlc_am_tx_data_pdu_management_t *pdu_mngt_p = NULL; - - sdu_size_t li_length_in_bytes = 0; - sdu_size_t test_li_length_in_bytes = 0; - sdu_size_t 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; - unsigned int sdu_buffer_index = 0; - sdu_size_t 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; - signed int max_li_overhead = 0; - - LOG_T(RLC, - PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] rlc_pP->current_sdu_index %d rlc_pP->next_sdu_index %d rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block %p sdu_buffer_occupancy %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->current_sdu_index, - rlc_pP->next_sdu_index, - rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block, - rlc_pP->sdu_buffer_occupancy); - - if (rlc_pP->sdu_buffer_occupancy <= 0) { - return; - } - - //msg ("[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT]\n", rlc_pP->module_id, rlc_pP->rb_id, ctxt_pP->frame); - list_init (&pdus, NULL); // param string identifying the list is NULL - pdu_mem_p = NULL; - - - RLC_AM_MUTEX_LOCK(&rlc_pP->lock_input_sdus, ctxt_pP, rlc_pP); - - while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block) && (nb_bytes_to_transmit > 0) ) { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] nb_bytes_to_transmit %d BO %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - nb_bytes_to_transmit, - rlc_pP->sdu_buffer_occupancy); - - // pdu_p management - if (!pdu_mem_p) { - if (rlc_pP->nb_sdu_no_segmented <= 1) { - max_li_overhead = 0; - } else { - /* This computation assumes there is no SDU with size greater than 2047 bytes, otherwise a new PDU must be built except for LI15 configuration from Rel12*/ - test_num_li = rlc_pP->nb_sdu_no_segmented - 1; - max_li_overhead = test_num_li + (test_num_li >> 1) + (test_num_li & 1); - } - - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] max_li_overhead %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - max_li_overhead); - - if (nb_bytes_to_transmit >= (rlc_pP->sdu_buffer_occupancy + RLC_AM_HEADER_MIN_SIZE + max_li_overhead)) { - data_pdu_size = rlc_pP->sdu_buffer_occupancy + RLC_AM_HEADER_MIN_SIZE + max_li_overhead; - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - data_pdu_size); - } else { - data_pdu_size = nb_bytes_to_transmit; - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - data_pdu_size); - } - - if (!(pdu_mem_p = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req), __func__))) { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - RLC_AM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); - return; - } - - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] get new PDU %d bytes\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - data_pdu_size); - pdu_remaining_size = data_pdu_size - RLC_AM_HEADER_MIN_SIZE; - pdu_p = (rlc_am_pdu_sn_10_t*) (&pdu_mem_p->data[sizeof(struct mac_tb_req)]); - pdu_tb_req_p = (struct mac_tb_req*) (pdu_mem_p->data); - pdu_mngt_p = &rlc_pP->tx_data_pdu_buffer[rlc_pP->vt_s % RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE]; - memset(pdu_mngt_p, 0, sizeof (rlc_am_tx_data_pdu_management_t)); - - memset (pdu_mem_p->data, 0, sizeof (rlc_am_pdu_sn_10_t)+sizeof(struct mac_tb_req)); - li_length_in_bytes = 1; - } - - //---------------------------------------- - // compute how many SDUS can fill the PDU - //---------------------------------------- - continue_fill_pdu_with_sdu = 1; - num_fill_sdu = 0; - test_num_li = 0; - sdu_buffer_index = rlc_pP->current_sdu_index; - 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].mem_block) && (continue_fill_pdu_with_sdu > 0)) { - sdu_mngt_p = &rlc_pP->input_sdus[sdu_buffer_index]; - - if (sdu_mngt_p->sdu_remaining_size > test_pdu_remaining_size) { - // no LI - continue_fill_pdu_with_sdu = 0; - num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - } else if (sdu_mngt_p->sdu_remaining_size == test_pdu_remaining_size) { - // fi will indicate end of PDU is end of SDU, no need for LI - continue_fill_pdu_with_sdu = 0; - num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - } else if ((sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) == test_pdu_remaining_size ) { - // no LI - continue_fill_pdu_with_sdu = 0; - num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - pdu_remaining_size = pdu_remaining_size - (test_li_length_in_bytes ^ 3); - } else if ((sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) < test_pdu_remaining_size ) { - if (pdu_mngt_p->nb_sdus >= (RLC_AM_MAX_SDU_IN_PDU-1)) { - continue_fill_pdu_with_sdu = 0; - //num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - pdu_remaining_size = pdu_remaining_size - 1; - } else { - test_num_li += 1; - num_fill_sdu += 1; - test_pdu_remaining_size = test_pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)); - test_remaining_size_to_substract = test_li_length_in_bytes ^ 3; - test_remaining_num_li_to_substract = 1; - test_li_length_in_bytes = test_li_length_in_bytes ^ 3; - } - } else { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] sdu_mngt_p->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p->sdu_remaining_size, - test_pdu_remaining_size, - test_li_length_in_bytes ^ 3); - // reduce the size of the PDU - continue_fill_pdu_with_sdu = 0; - num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - pdu_remaining_size = pdu_remaining_size - 1; - } - - pdu_mngt_p->sdus_index[pdu_mngt_p->nb_sdus++] = sdu_buffer_index; - sdu_mngt_p->pdus_index[sdu_mngt_p->nb_pdus++] = rlc_pP->vt_s % RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE; - //assert(sdu_mngt_p->nb_pdus < RLC_AM_MAX_SDU_FRAGMENTS); - if(sdu_mngt_p->nb_pdus >= RLC_AM_MAX_SDU_FRAGMENTS) { - LOG_E(RLC,PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] loop error. %d %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->nb_pdus, RLC_AM_MAX_SDU_FRAGMENTS); - break; - } - sdu_buffer_index = (sdu_buffer_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; - } - - if (test_remaining_num_li_to_substract > 0) { - // there is a LI that is not necessary - test_num_li = test_num_li - 1; - pdu_remaining_size = pdu_remaining_size - test_remaining_size_to_substract; - } - - //---------------------------------------- - // Do the real filling of the pdu_p - //---------------------------------------- - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT" data shift %d Bytes num_li %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - ((test_num_li*3) +1) >> 1, - test_num_li); - data = ((unsigned char*)(&pdu_p->data[((test_num_li*3) +1) >> 1])); - pdu_mngt_p->payload = data; - e_li_p = (rlc_am_e_li_t*)(pdu_p->data); - continue_fill_pdu_with_sdu = 1; - li_length_in_bytes = 1; - fill_num_li = 0; - fi_first_byte_pdu_is_first_byte_sdu = 0; - fi_last_byte_pdu_is_last_byte_sdu = 0; - - if (rlc_pP->input_sdus[rlc_pP->current_sdu_index].sdu_remaining_size == - rlc_pP->input_sdus[rlc_pP->current_sdu_index].sdu_size) { - fi_first_byte_pdu_is_first_byte_sdu = 1; - } - - while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block) && (continue_fill_pdu_with_sdu > 0)) { - sdu_mngt_p = &rlc_pP->input_sdus[rlc_pP->current_sdu_index]; - - if (sdu_mngt_p->sdu_segmented_size == 0) { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p, - sdu_mngt_p->sdu_remaining_size); - } else { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes LENGTH \n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p, - sdu_mngt_p->sdu_remaining_size, - sdu_mngt_p->sdu_size); - } - - data_sdu_p = &sdu_mngt_p->first_byte[sdu_mngt_p->sdu_segmented_size]; - - if (sdu_mngt_p->sdu_remaining_size > pdu_remaining_size) { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] Filling all remaining PDU with %d bytes\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_remaining_size); - //msg ("[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] pdu_mem_p %p pdu_p %p pdu_p->data %p data %p data_sdu_p %p pdu_remaining_size %d\n", rlc_pP->module_id, rlc_pP->rb_id, ctxt_pP->frame, pdu_mem_p, pdu_p, pdu_p->data, data, data_sdu_p,pdu_remaining_size); - - memcpy(data, data_sdu_p, pdu_remaining_size); - pdu_mngt_p->payload_size += pdu_remaining_size; - sdu_mngt_p->sdu_remaining_size = sdu_mngt_p->sdu_remaining_size - pdu_remaining_size; - sdu_mngt_p->sdu_segmented_size = sdu_mngt_p->sdu_segmented_size + pdu_remaining_size; - fi_last_byte_pdu_is_last_byte_sdu = 0; - // no LI - rlc_pP->sdu_buffer_occupancy -= pdu_remaining_size; - continue_fill_pdu_with_sdu = 0; - pdu_remaining_size = 0; - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] sdu_remaining_size %d bytes sdu_segmented_size %d bytes\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p->sdu_remaining_size, - sdu_mngt_p->sdu_segmented_size); - } else if (sdu_mngt_p->sdu_remaining_size == pdu_remaining_size) { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] Exactly Filling remaining PDU with %d remaining bytes of SDU\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_remaining_size); - rlc_am_mui.rrc_mui[rlc_am_mui.rrc_mui_num] = sdu_mngt_p->mui; - rlc_am_mui.rrc_mui_num++; - - memcpy(data, data_sdu_p, pdu_remaining_size); - pdu_mngt_p->payload_size += pdu_remaining_size; - - // free SDU - rlc_pP->sdu_buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; - rlc_am_free_in_sdu_data(ctxt_pP, rlc_pP, rlc_pP->current_sdu_index); - //free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index], __func__); - //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_AM_SDU_CONTROL_BUFFER_SIZE; - - fi_last_byte_pdu_is_last_byte_sdu = 1; - // fi will indicate end of PDU is end of SDU, no need for LI - continue_fill_pdu_with_sdu = 0; - pdu_remaining_size = 0; - } else if ((sdu_mngt_p->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { - if (fill_num_li == (RLC_AM_MAX_SDU_IN_PDU - 1)) { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] [SIZE %d] REACHING RLC_AM_MAX_SDU_IN_PDU LIs -> STOP SEGMENTATION FOR THIS PDU SDU\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p->sdu_remaining_size); - memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); - pdu_mngt_p->payload_size += sdu_mngt_p->sdu_remaining_size; - pdu_remaining_size = 0; //Forced to 0 pdu_remaining_size - sdu_mngt_p->sdu_remaining_size; - // free SDU - rlc_pP->sdu_buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; - rlc_am_free_in_sdu_data(ctxt_pP, rlc_pP, 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_AM_SDU_CONTROL_BUFFER_SIZE; - - // reduce the size of the PDU - continue_fill_pdu_with_sdu = 0; - fi_last_byte_pdu_is_last_byte_sdu = 1; - rlc_am_mui.rrc_mui[rlc_am_mui.rrc_mui_num] = sdu_mngt_p->mui; - rlc_am_mui.rrc_mui_num++; - } else { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] Filling PDU with %d all remaining bytes of SDU\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p->sdu_remaining_size); - memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); - pdu_mngt_p->payload_size += sdu_mngt_p->sdu_remaining_size; - data = &data[sdu_mngt_p->sdu_remaining_size]; - li_length_in_bytes = li_length_in_bytes ^ 3; - fill_num_li += 1; - - if (li_length_in_bytes == 2) { - if (fill_num_li == test_num_li) { - //e_li_p->e1 = 0; - e_li_p->b1 = 0; - } else { - //e_li_p->e1 = 1; - e_li_p->b1 = 0x80; - } - - //e_li_p->li1 = sdu_mngt_p->sdu_remaining_size; - e_li_p->b1 = e_li_p->b1 | (sdu_mngt_p->sdu_remaining_size >> 4); - e_li_p->b2 = sdu_mngt_p->sdu_remaining_size << 4; - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] set e_li_p->b1=0x%02X set e_li_p->b2=0x%02X fill_num_li=%d test_num_li=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - e_li_p->b1, - e_li_p->b2, - fill_num_li, - test_num_li); - } else { - if (fill_num_li != test_num_li) { - //e_li_p->e2 = 1; - e_li_p->b2 = e_li_p->b2 | 0x08; - } - - //e_li_p->li2 = sdu_mngt_p->sdu_remaining_size; - e_li_p->b2 = e_li_p->b2 | (sdu_mngt_p->sdu_remaining_size >> 8); - e_li_p->b3 = sdu_mngt_p->sdu_remaining_size & 0xFF; - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] set e_li_p->b2=0x%02X set e_li_p->b3=0x%02X fill_num_li=%d test_num_li=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - e_li_p->b2, - e_li_p->b3, - fill_num_li, - test_num_li); - e_li_p++; - } - - pdu_remaining_size = pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + li_length_in_bytes); - // free SDU - rlc_pP->sdu_buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; - sdu_mngt_p->sdu_remaining_size = 0; - - rlc_am_free_in_sdu_data(ctxt_pP, rlc_pP, rlc_pP->current_sdu_index); - //free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index], __func__); - //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_AM_SDU_CONTROL_BUFFER_SIZE; - } - } else { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p->sdu_remaining_size, - pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); - //assert(1!=1); - rlc_am_mui.rrc_mui[rlc_am_mui.rrc_mui_num] = sdu_mngt_p->mui; - rlc_am_mui.rrc_mui_num++; - - memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); - pdu_mngt_p->payload_size += sdu_mngt_p->sdu_remaining_size; - pdu_remaining_size = pdu_remaining_size - sdu_mngt_p->sdu_remaining_size; - // free SDU - rlc_pP->sdu_buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; - rlc_am_free_in_sdu_data(ctxt_pP, rlc_pP, 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_AM_SDU_CONTROL_BUFFER_SIZE; - - // reduce the size of the PDU - continue_fill_pdu_with_sdu = 0; - fi_last_byte_pdu_is_last_byte_sdu = 1; - } - } - - // set framing info - if (fi_first_byte_pdu_is_first_byte_sdu) { - fi = 0; - } else { - fi = 2; - } - - if (!fi_last_byte_pdu_is_last_byte_sdu) { - fi = fi + 1; - } - - pdu_p->b1 = pdu_p->b1 | (fi << RLC_AM_PDU_FI_OFFSET); - - // set fist e bit - if (fill_num_li > 0) { - RLC_AM_PDU_SET_E(pdu_p->b1); - } - - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] SEND PDU SN %04d SIZE %d BYTES PAYLOAD SIZE %d BYTES\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->vt_s, - data_pdu_size - pdu_remaining_size, - pdu_mngt_p->payload_size); - - rlc_pP->stat_tx_data_pdu += 1; - rlc_pP->stat_tx_data_bytes += (data_pdu_size - pdu_remaining_size); - - // set DATA/CONTROL field is DATA PDU(1) - RLC_AM_PDU_SET_D_C(pdu_p->b1); - // set sn = rlc_pP->vt_s; - pdu_p->b1 = pdu_p->b1 | (rlc_pP->vt_s >> 8); - pdu_p->b2 = rlc_pP->vt_s & 0xFF; - rlc_pP->vt_s = (rlc_pP->vt_s+1) & RLC_AM_SN_MASK; - - pdu_tb_req_p->data_ptr = (unsigned char*)pdu_p; - pdu_tb_req_p->tb_size = data_pdu_size - pdu_remaining_size; -//#warning "why 3000: changed to RLC_SDU_MAX_SIZE " - //assert(pdu_tb_req_p->tb_size < RLC_SDU_MAX_SIZE ); - if(pdu_tb_req_p->tb_size >= RLC_SDU_MAX_SIZE) { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] tb_size error. %d, %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_tb_req_p->tb_size, RLC_SDU_MAX_SIZE); - } - rlc_am_pdu_polling(ctxt_pP, rlc_pP, pdu_p, pdu_mngt_p->payload_size,true); - - //list_add_tail_eurecom (pdu_mem_p, &rlc_pP->segmentation_pdu_list); - pdu_mngt_p->mem_block = pdu_mem_p; - pdu_mngt_p->first_byte = (unsigned char*)pdu_p; - pdu_mngt_p->header_and_payload_size = data_pdu_size - pdu_remaining_size; - pdu_mngt_p->retx_count = 0; - pdu_mngt_p->retx_count_next = 0; - pdu_mngt_p->flags.retransmit = 0; - pdu_mngt_p->flags.transmitted = 1; - pdu_mngt_p->sn = RLC_AM_PREV_SN(rlc_pP->vt_s); - - - //TBC: What for resetting local pointers at the end ?? - pdu_p = NULL; - pdu_mem_p = NULL; - - //nb_bytes_to_transmit = nb_bytes_to_transmit - data_pdu_size; - nb_bytes_to_transmit = 0; // 1 PDU only - - /* We need to copy the PDU to pass to MAC in order to keep it in the buffer for potential retransmissions */ - mem_block_t* copy = rlc_am_retransmit_get_copy (ctxt_pP, rlc_pP, RLC_AM_PREV_SN(rlc_pP->vt_s)); - list_add_tail_eurecom (copy, &rlc_pP->segmentation_pdu_list); - - } - - RLC_AM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.h deleted file mode 100644 index 1e472302c82effd27fdf38c92218d65e3a91c897..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_segment.h -* \brief This file defines the prototypes of the functions dealing with the segmentation of PDCP SDUs. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_internal_segment_impl_ RLC AM Segmentation Internal Reference Implementation -* @ingroup _rlc_am_internal_impl_ -* @{ -*/ -# ifndef __RLC_AM_SEGMENT_H__ -# define __RLC_AM_SEGMENT_H__ -//----------------------------------------------------------------------------- - -/*! \fn void rlc_am_pdu_polling (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *const rlcP, rlc_am_pdu_sn_10_t *pduP, int16_t payload_sizeP, bool is_new_pdu) -* \brief Set or not the poll bit in the PDU header depending on RLC AM protocol variables. -* \param[in] ctxt_pP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] pduP Pointer on the header of the PDU in order to be able to set the poll bit if necessary. -* \param[in] payload_sizeP Size of the payload of the PDU. -*/ -void rlc_am_pdu_polling (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t *const rlcP, rlc_am_pdu_sn_10_t *pduP, int16_t payload_sizeP, bool is_new_pdu); - -/*! \fn void rlc_am_segment_10 (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlcP) -* \brief Segment a PDU with 10 bits sequence number, based on segmentation information given by MAC (size to transmit). -* \param[in] ctxt_pP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -*/ -void rlc_am_segment_10 (const protocol_ctxt_t* const ctxt_pP,rlc_am_entity_t *const rlcP); -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.c deleted file mode 100644 index a696f9a9f1bb0a0dbb31d83acff806c4684b18d6..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/* This file is empty. Might be deleted ? */ diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.h deleted file mode 100644 index 0b237b07f421b48dce381cee05cd18fb2d167437..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_segments_holes.h -* \brief This file defines the prototypes of the functions dealing with the re-segmentation of RLC PDUs stored in the retransmission buffer,. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_segment_holes_impl_ RLC AM Resegmentation Implementation -* @ingroup _rlc_am_internal_segment_impl_ -* @{ -*/ -#ifndef __RLC_AM_SEGMENT_HOLES_H__ -# define __RLC_AM_SEGMENT_HOLES_H__ -//----------------------------------------------------------------------------- -/*! \fn void rlc_am_clear_holes (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlcP, rlc_sn_t snP) -* \brief Remove all marked holes for PDU with sequence number "snP". -* \param[in] ctxt_pP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] snP Sequence number. -*/ -void rlc_am_clear_holes ( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlcP, - const rlc_sn_t snP); - -/*! \fn void rlc_am_remove_hole (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlcP, rlc_sn_t snP, sdu_size_t so_startP, sdu_size_t so_stopP) -* \brief Remove for PDU with sequence number "snP" a NACK for byte segment offset [so_startP, so_stopP]. -* \param[in] ctxt_pP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] snP Sequence number. -* \param[in] so_startP Start of segment offset. -* \param[in] so_stopP End of segment offset. -*/ -void rlc_am_remove_hole ( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlcP, - const rlc_sn_t snP, - const sdu_size_t so_startP, - const sdu_size_t so_stopP); - -/*! \fn void rlc_am_get_next_hole (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlcP, rlc_sn_t snP, sdu_size_t* so_startP, sdu_size_t* so_stopP) -* \brief Get for PDU with sequence number "snP" the first hole start and stop parameters. -* \param[in] ctxt_pP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] snP Sequence number. -* \param[in,out] so_startP Start of segment offset. -* \param[in,out] so_stopP End of segment offset. -*/ -void rlc_am_get_next_hole ( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlcP, - const rlc_sn_t snP, - sdu_size_t* const so_startP, - sdu_size_t* const so_stopP); - -/*! \fn void rlc_am_add_hole (const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t * const rlcP, rlc_sn_t snP, sdu_size_t so_startP, sdu_size_t so_stopP) -* \brief Mark for PDU with sequence number "snP" a NACK for byte segment offset [so_startP, so_stopP]. -* \param[in] ctxt_pP Running context. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] snP Sequence number. -* \param[in,out] so_startP Start of segment offset. -* \param[in,out] so_stopP End of segment offset. -*/ -void rlc_am_add_hole ( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlcP, - const rlc_sn_t snP, - const sdu_size_t so_startP, - sdu_size_t so_stopP); -/** @} */ -#endif 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 deleted file mode 100644 index f1e6c961e704ee5ce26cf9a5b1dce2d1512cb02c..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c +++ /dev/null @@ -1,764 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_STATUS_REPORT_C 1 -//----------------------------------------------------------------------------- -#include <string.h> -//----------------------------------------------------------------------------- -#include "platform_types.h" -//----------------------------------------------------------------------------- -#include "intertask_interface.h" -#include "assertions.h" -#include "list.h" -#include "rlc_am.h" -#include "common/utils/LOG/log.h" - - -//----------------------------------------------------------------------------- -uint16_t rlc_am_read_bit_field( - uint8_t **data_ppP, - unsigned int *bit_pos_pP, - const signed int bits_to_readP) { - uint16_t value = 0; - unsigned int bits_read = 0; - signed int bits_to_read = bits_to_readP; - - do { - // bits read > bits to read - if ((8 - *bit_pos_pP) > bits_to_read) { - bits_read = 8 - *bit_pos_pP; - value = (value << bits_to_read) | ((((uint16_t)(**data_ppP)) & (uint16_t)(0x00FF >> *bit_pos_pP)) >> (bits_read - - bits_to_read)); - *bit_pos_pP = *bit_pos_pP + bits_to_read; - return value; - // bits read == bits to read - } else if ((8 - *bit_pos_pP) == bits_to_read) { - value = (value << bits_to_read) | (((uint16_t)(**data_ppP)) & (uint16_t)(0x00FF >> *bit_pos_pP)); - *bit_pos_pP = 0; - *data_ppP = *data_ppP + 1; - return value; - // bits read < bits to read - } else { - bits_read = 8 - *bit_pos_pP; - value = (value << bits_read) | ((((uint16_t)(**data_ppP)) & (uint16_t)(0x00FF >> *bit_pos_pP))); - *bit_pos_pP = 0; - *data_ppP = *data_ppP + 1; - bits_to_read = bits_to_read - bits_read; - } - } while (bits_to_read > 0); - - return value; -} -//----------------------------------------------------------------------------- -void -rlc_am_write8_bit_field( - uint8_t **data_ppP, - unsigned int *bit_pos_pP, - const signed int bits_to_writeP, - const uint8_t valueP) { - unsigned int available_bits; - signed int bits_to_write= bits_to_writeP; - - do { - available_bits = 8 - *bit_pos_pP; - - // available_bits > bits to write - if (available_bits > bits_to_write) { - **data_ppP = **data_ppP | (((valueP & (((uint8_t)0xFF) >> (available_bits - bits_to_write)))) << (available_bits - - bits_to_write)); - *bit_pos_pP = *bit_pos_pP + bits_to_write; - return; - // bits read == bits to read - } else if (available_bits == bits_to_write) { - **data_ppP = **data_ppP | (valueP & (((uint8_t)0xFF) >> (8 - bits_to_write))); - *bit_pos_pP = 0; - *data_ppP = *data_ppP + 1; - return; - // available_bits < bits to write - } else { - **data_ppP = **data_ppP | (valueP >> (bits_to_write - available_bits)); - *bit_pos_pP = 0; - *data_ppP = *data_ppP + 1; - bits_to_write = bits_to_write - available_bits; - } - } while (bits_to_write > 0); -} -//----------------------------------------------------------------------------- -void -rlc_am_write16_bit_field( - uint8_t **data_ppP, - unsigned int *bit_pos_pP, - signed int bits_to_writeP, - const uint16_t valueP) { - //assert(bits_to_writeP <= 16); - if(bits_to_writeP > 16) { - LOG_E(RLC, "bits_to_writeP error. %d\n", bits_to_writeP); - } - - if (bits_to_writeP > 8) { - rlc_am_write8_bit_field(data_ppP,bit_pos_pP, bits_to_writeP - 8, (uint8_t)(valueP >> 8)); - rlc_am_write8_bit_field(data_ppP,bit_pos_pP, 8, (uint8_t)(valueP & 0x00FF)); - } else { - rlc_am_write8_bit_field(data_ppP,bit_pos_pP, bits_to_writeP, (uint8_t)(valueP & 0x00FF)); - } -} -//----------------------------------------------------------------------------- -signed int -rlc_am_get_control_pdu_infos( - rlc_am_pdu_sn_10_t *const header_pP, - sdu_size_t *const total_size_pP, - rlc_am_control_pdu_info_t *const pdu_info_pP) { - memset(pdu_info_pP, 0, sizeof (rlc_am_control_pdu_info_t)); - pdu_info_pP->d_c = header_pP->b1 >> 7; - - if (!pdu_info_pP->d_c) { - pdu_info_pP->cpt = (header_pP->b1 >> 4) & 0x07; - - if (pdu_info_pP->cpt != 0x00) { - return -3; - } - - pdu_info_pP->ack_sn = ((header_pP->b2 >> 2) & 0x3F) | (((uint16_t)(header_pP->b1 & 0x0F)) << 6); - pdu_info_pP->e1 = (header_pP->b2 >> 1) & 0x01; - //*total_size_pP -= 1; - - if (pdu_info_pP->e1) { - unsigned int nack_to_read = 1; - unsigned int bit_pos = 7; // range from 0 (MSB/left) to 7 (LSB/right) - uint8_t *byte_pos_p = &header_pP->b2; - - while (nack_to_read) { - pdu_info_pP->nack_list[pdu_info_pP->num_nack].nack_sn = rlc_am_read_bit_field(&byte_pos_p, &bit_pos, 10); - pdu_info_pP->nack_list[pdu_info_pP->num_nack].e1 = rlc_am_read_bit_field(&byte_pos_p, &bit_pos, 1); - pdu_info_pP->nack_list[pdu_info_pP->num_nack].e2 = rlc_am_read_bit_field(&byte_pos_p, &bit_pos, 1); - - // READ SOstart, SOend field - if (pdu_info_pP->nack_list[pdu_info_pP->num_nack].e2) { - pdu_info_pP->nack_list[pdu_info_pP->num_nack].so_start = rlc_am_read_bit_field(&byte_pos_p, &bit_pos, 15); - pdu_info_pP->nack_list[pdu_info_pP->num_nack].so_end = rlc_am_read_bit_field(&byte_pos_p, &bit_pos, 15); - } else { - pdu_info_pP->nack_list[pdu_info_pP->num_nack].so_start = 0; - // all 15 bits set to 1 (indicate that the missing portion of the AMD PDU includes all bytes - // to the last byte of the AMD PDU) - pdu_info_pP->nack_list[pdu_info_pP->num_nack].so_end = 0x7FFF; - } - - pdu_info_pP->num_nack = pdu_info_pP->num_nack + 1; - - if (!pdu_info_pP->nack_list[pdu_info_pP->num_nack - 1].e1) { - nack_to_read = 0; - *total_size_pP = *total_size_pP - (sdu_size_t)((uint64_t)byte_pos_p + (uint64_t)((bit_pos + 7)/8) - (uint64_t)header_pP); - - if (*total_size_pP != 0) { - LOG_E(RLC, "[RLC_AM_GET_CONTROL_PDU_INFOS][FIRST]header_pP->b1=%d,header_pP->b2=%d\n",header_pP->b1,header_pP->b2); - } - - return 0; - } - - if (pdu_info_pP->num_nack == RLC_AM_MAX_NACK_IN_STATUS_PDU) { - *total_size_pP = *total_size_pP - (sdu_size_t)((uint64_t)byte_pos_p + (uint64_t)((bit_pos + 7)/8) - (uint64_t)header_pP); - return -2; - } - } - - *total_size_pP = *total_size_pP - (sdu_size_t)((uint64_t)byte_pos_p + (uint64_t)((bit_pos + 7)/8) - (uint64_t)header_pP); - } else { - *total_size_pP = *total_size_pP - 2; - } - - if (*total_size_pP != 0) { - LOG_E(RLC, "[RLC_AM_GET_CONTROL_PDU_INFOS][SECOND]header_pP->b1=%d,header_pP->b2=%d\n",header_pP->b1,header_pP->b2); - } - - return 0; - } else { - return -1; - } -} -//----------------------------------------------------------------------------- -void -rlc_am_display_control_pdu_infos( - const rlc_am_control_pdu_info_t *const pdu_info_pP -) { - int num_nack; - - if (!pdu_info_pP->d_c) { - LOG_T(RLC, "CONTROL PDU ACK SN %04d", pdu_info_pP->ack_sn); - - for (num_nack = 0; num_nack < pdu_info_pP->num_nack; num_nack++) { - if (pdu_info_pP->nack_list[num_nack].e2) { - LOG_T(RLC, "\n\tNACK SN %04d SO START %05d SO END %05d", pdu_info_pP->nack_list[num_nack].nack_sn, - pdu_info_pP->nack_list[num_nack].so_start, - pdu_info_pP->nack_list[num_nack].so_end); - } else { - LOG_T(RLC, "\n\tNACK SN %04d", pdu_info_pP->nack_list[num_nack].nack_sn); - } - } - - LOG_T(RLC, "\n"); - } else { - LOG_E(RLC, "CAN'T DISPLAY CONTROL INFO: PDU IS DATA PDU\n"); - } -} -//----------------------------------------------------------------------------- -void -rlc_am_receive_process_control_pdu( - const protocol_ctxt_t *const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - mem_block_t *const tb_pP, - uint8_t **first_byte_ppP, - sdu_size_t *const tb_size_in_bytes_pP) { - 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_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 = (rlc_sn_t) 0; - rlc_sn_t nack_sn,prev_nack_sn; - sdu_size_t data_cnf_so_stop = 0x7FFF; - unsigned int nack_index; - bool status = true; - - if (rlc_am_get_control_pdu_infos(rlc_am_pdu_sn_10_p, tb_size_in_bytes_pP, &rlc_pP->control_pdu_info) >= 0) { - rlc_am_tx_buffer_display(ctxt_pP, rlc_pP, " TX BUFFER BEFORE PROCESS OF STATUS PDU"); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" RX CONTROL PDU VT(A) %04d VT(S) %04d POLL_SN %04d ACK_SN %04d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->vt_a, - rlc_pP->vt_s, - rlc_pP->poll_sn, - 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 - // by its peer AM RLC entity) for an AMD PDU or a portion of an AMD PDU by the following: - // - STATUS PDU from its peer AM RLC entity. - // - // When receiving a negative acknowledgement for an AMD PDU or a portion of an AMD PDU by a STATUS PDU from - // its peer AM RLC entity, the transmitting side of the AM RLC entity shall: - // - if the SN of the corresponding AMD PDU falls within the range VT(A) <= SN < VT(S): - // - consider the AMD PDU or the portion of the AMD PDU for which a negative acknowledgement was - // received for retransmission. - - // 5.2.2.2 Reception of a STATUS report - // Upon reception of a STATUS report from the receiving RLC AM entity the - // transmitting side of an AM RLC entity shall: - // - if the STATUS report comprises a positive or negative - // acknowledgement for the RLC data PDU with sequence number equal to - // POLL_SN: - // - if t-PollRetransmit is running: - // - stop and reset t-PollRetransmit. - //assert(ack_sn < RLC_AM_SN_MODULO); - //assert(rlc_pP->control_pdu_info.num_nack < RLC_AM_MAX_NACK_IN_STATUS_PDU); - if(ack_sn >= RLC_AM_SN_MODULO || rlc_pP->control_pdu_info.num_nack >= RLC_AM_MAX_NACK_IN_STATUS_PDU) { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" illegal ack_sn %d, num_nack %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), ack_sn, rlc_pP->control_pdu_info.num_nack); - return; - } - - /* Note : ackSn can be equal to current vtA only in case the status pdu contains a list of nack_sn with same value = vtA with SOStart/SOEnd */ - /* and meaning the report is not complete due to not enough ressources to fill all SOStart/SOEnd of this NACK_SN */ - if (RLC_AM_DIFF_SN(rlc_pP->vt_s,rlc_pP->vt_a) >= RLC_AM_DIFF_SN(ack_sn,rlc_pP->vt_a)) { - if (rlc_pP->control_pdu_info.num_nack == 0) { - while (sn_cursor != ack_sn) { - rlc_am_ack_pdu(ctxt_pP, rlc_pP, sn_cursor, true); - sn_cursor = RLC_AM_NEXT_SN(sn_cursor); - } - - vt_a_new = ack_sn; - sn_data_cnf = RLC_AM_PREV_SN(vt_a_new); - } else { - nack_index = 0; - nack_sn = rlc_pP->control_pdu_info.nack_list[nack_index].nack_sn; - prev_nack_sn = 0x3FFF; - - while (sn_cursor != nack_sn) { - rlc_am_ack_pdu(ctxt_pP, rlc_pP, sn_cursor, true); - sn_cursor = RLC_AM_NEXT_SN(sn_cursor); - } - - 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_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); - } else if (tx_data_pdu_buffer_p->nack_so_start != 0) { - sn_data_cnf = nack_sn; - data_cnf_so_stop = tx_data_pdu_buffer_p->nack_so_start - 1; - } else { - sn_data_cnf = RLC_AM_PREV_SN(nack_sn); - } - - while ((sn_cursor != ack_sn) && (status)) { - if (sn_cursor != nack_sn) { - rlc_am_ack_pdu(ctxt_pP, - rlc_pP, - sn_cursor, - false); - } else { - status = rlc_am_nack_pdu (ctxt_pP, - rlc_pP, - nack_sn, - prev_nack_sn, - rlc_pP->control_pdu_info.nack_list[nack_index].so_start, - rlc_pP->control_pdu_info.nack_list[nack_index].so_end); - nack_index = nack_index + 1; - prev_nack_sn = nack_sn; - - if (nack_index < rlc_pP->control_pdu_info.num_nack) { - nack_sn = rlc_pP->control_pdu_info.nack_list[nack_index].nack_sn; - } else if (nack_sn != ack_sn) { - /* general case*/ - nack_sn = ack_sn; - } else { - /*specific case when the sender did not have enough TBS to fill all SOStart SOEnd for this NACK_SN */ - break; - } - } - - if (prev_nack_sn != nack_sn) { - /* do not increment sn_cursor in case of several informations for the same nack_sn */ - sn_cursor = (sn_cursor + 1) & RLC_AM_SN_MASK; - } - } - } - } else { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" WARNING CONTROL PDU ACK SN %d OUT OF WINDOW vtA=%d vtS=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),ack_sn,rlc_pP->vt_a,rlc_pP->vt_s); - *tb_size_in_bytes_pP = 0; - status = false; - } - } else { - LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" ERROR IN DECODING CONTROL PDU\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - *tb_size_in_bytes_pP = 0; - status = false; - } - - if (status) { - /* Check for Stopping TpollReTx */ - if ((rlc_pP->poll_sn != RLC_SN_UNDEFINED) && - (RLC_AM_DIFF_SN(ack_sn,rlc_pP->vt_a) > RLC_AM_DIFF_SN(rlc_pP->poll_sn,rlc_pP->vt_a))) { - rlc_am_stop_and_reset_timer_poll_retransmit(ctxt_pP, rlc_pP); - rlc_pP->poll_sn = RLC_SN_UNDEFINED; - } - - //TODO : this part does not cover all cases of Data Cnf and move it at the end of Status PDU processing - sn_cursor = rlc_pP->vt_a; - - // Fix Issue 238 : check sn_data_cnf has been transmitted - if ((rlc_pP->tx_data_pdu_buffer[sn_data_cnf % RLC_AM_WINDOW_SIZE].flags.transmitted) && - (rlc_pP->tx_data_pdu_buffer[sn_data_cnf % RLC_AM_WINDOW_SIZE].sn == sn_data_cnf)) { - /* Handle all acked PDU up to and excluding sn_data_cnf */ - while (sn_cursor != sn_data_cnf) { - rlc_am_pdu_sdu_data_cnf(ctxt_pP,rlc_pP,sn_cursor); - sn_cursor = RLC_AM_NEXT_SN(sn_cursor); - } - - // Handle last SN. TO DO : case of PDU partially ACKED with SDU to be data conf - if (data_cnf_so_stop == 0x7FFF) { - rlc_am_pdu_sdu_data_cnf(ctxt_pP,rlc_pP,sn_data_cnf); - } - - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" RECEIVE STATUS PDU ACK_SN=%d NewvtA=%d OldvtA=%d SnDataCnf=%d DataCnfSOStop=%d vtS=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),ack_sn,vt_a_new,rlc_pP->vt_a,sn_data_cnf,data_cnf_so_stop,rlc_pP->vt_s); - } else { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" RECEIVE STATUS PDU WITH NO SDU CNF ACK_SN=%d NewvtA=%d OldvtA=%d vtS=%d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),ack_sn,vt_a_new,rlc_pP->vt_a,rlc_pP->vt_s); - } - - /* Update vtA and vtMS */ - rlc_pP->vt_a = vt_a_new; - rlc_pP->vt_ms = (rlc_pP->vt_a + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; - } - - *first_byte_ppP = (uint8_t *)((uint64_t)*first_byte_ppP + initial_pdu_size - *tb_size_in_bytes_pP); - free_mem_block(tb_pP, __func__); - rlc_am_tx_buffer_display(ctxt_pP, rlc_pP, NULL); -} -//----------------------------------------------------------------------------- -int -rlc_am_write_status_pdu( - const protocol_ctxt_t *const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - rlc_am_pdu_sn_10_t *const rlc_am_pdu_sn_10_pP, - rlc_am_control_pdu_info_t *const pdu_info_pP) { - unsigned int bit_pos = 4; // range from 0 (MSB/left) to 7 (LSB/right) - uint8_t *byte_pos_p = &rlc_am_pdu_sn_10_pP->b1; - unsigned int index = 0; - unsigned int num_bytes = 0; - rlc_am_write16_bit_field(&byte_pos_p, &bit_pos, 10, pdu_info_pP->ack_sn); - - if (pdu_info_pP->num_nack > 0) { - rlc_am_write8_bit_field(&byte_pos_p, &bit_pos, 1, 1); - } else { - rlc_am_write8_bit_field(&byte_pos_p, &bit_pos, 1, 0); - } - - for (index = 0; index < pdu_info_pP->num_nack ; index++) { - rlc_am_write16_bit_field(&byte_pos_p, &bit_pos, 10, pdu_info_pP->nack_list[index].nack_sn); - rlc_am_write8_bit_field(&byte_pos_p, &bit_pos, 1, pdu_info_pP->nack_list[index].e1); - rlc_am_write8_bit_field(&byte_pos_p, &bit_pos, 1, pdu_info_pP->nack_list[index].e2); - - // if SO_START SO_END fields - if (pdu_info_pP->nack_list[index].e2 > 0) { - rlc_am_write16_bit_field(&byte_pos_p, &bit_pos, 15, pdu_info_pP->nack_list[index].so_start); - rlc_am_write16_bit_field(&byte_pos_p, &bit_pos, 15, pdu_info_pP->nack_list[index].so_end); - } - } - - ptrdiff_t diff = byte_pos_p - &rlc_am_pdu_sn_10_pP->b1; // this is the difference in terms of typeof(byte_pos_p), which is uint8_t - num_bytes = diff; - - if (bit_pos > 0) { - num_bytes += 1; - } - - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" WROTE STATUS PDU %d BYTES\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - num_bytes); - return num_bytes; -} -//----------------------------------------------------------------------------- -void -rlc_am_send_status_pdu( - const protocol_ctxt_t *const ctxt_pP, - rlc_am_entity_t *const rlc_pP -) { - // When STATUS reporting has been triggered, the receiving side of an AM RLC entity shall: - // - if t-StatusProhibit is not running: - // - at the first transmission opportunity indicated by lower layer, construct a STATUS PDU and deliver it to lower layer; - // - else: - // - at the first transmission opportunity indicated by lower layer after t-StatusProhibit expires, construct a single - // STATUS PDU even if status reporting was triggered several times while t-StatusProhibit was running and - // deliver it to lower layer; - // - // When a STATUS PDU has been delivered to lower layer, the receiving side of an AM RLC entity shall: - // - start t-StatusProhibit. - // - // When constructing a STATUS PDU, the AM RLC entity shall: - // - for the AMD PDUs with SN such that VR(R) <= SN < VR(MR) that has not been completely received yet, in - // increasing SN of PDUs and increasing byte segment order within PDUs, starting with SN = VR(R) up to - // the point where the resulting STATUS PDU still fits to the total size of RLC PDU(s) indicated by lower layer: - // - for an AMD PDU for which no byte segments have been received yet:: - // - include in the STATUS PDU a NACK_SN which is set to the SN of the AMD PDU; - // - for a continuous sequence of byte segments of a partly received AMD PDU that have not been received yet: - // - include in the STATUS PDU a set of NACK_SN, SOstart and SOend - // - set the ACK_SN to the SN of the next not received RLC Data PDU which is not indicated as missing in the - // resulting STATUS PDU. - signed int nb_bits_to_transmit = rlc_pP->nb_bytes_requested_by_mac << 3; - // minimum header size in bits to be transmitted: D/C + CPT + ACK_SN + E1 - signed int nb_bits_transmitted = RLC_AM_PDU_D_C_BITS + RLC_AM_STATUS_PDU_CPT_LENGTH + RLC_AM_SN_BITS + RLC_AM_PDU_E_BITS; - rlc_am_control_pdu_info_t control_pdu_info; - rlc_am_pdu_info_t *pdu_info_cursor_p = NULL; - rlc_sn_t sn_cursor = 0; - rlc_sn_t sn_nack = rlc_pP->vr_r; - mem_block_t *cursor_p = rlc_pP->receiver_buffer.head; - int all_segments_received = 0; - int waited_so = 0; - mem_block_t *tb_p = NULL; - sdu_size_t pdu_size = 0; - bool status_report_completed = false; - bool segment_loop_end = false; - memset(&control_pdu_info, 0, sizeof(rlc_am_control_pdu_info_t)); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] nb_bits_to_transmit %d (15 already allocated for header)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - nb_bits_to_transmit); - rlc_am_rx_list_display(rlc_pP, " DISPLAY BEFORE CONSTRUCTION OF STATUS REPORT"); - - /* Handle no NACK first */ - if (rlc_pP->vr_r == rlc_pP->vr_ms) { - control_pdu_info.ack_sn = rlc_pP->vr_ms; - status_report_completed = true; - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d ALL ACK WITH ACK_SN %04d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - __LINE__, - rlc_pP->vr_ms); - } else if ((cursor_p != NULL) && ((nb_bits_transmitted + RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1)) <= nb_bits_to_transmit)) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t *)(cursor_p->data))->pdu_info; - sn_cursor = pdu_info_cursor_p->sn; - /* Set E1 bit for the presence of first NACK_SN/E1/E2 */ - control_pdu_info.e1 = 1; - - // 12 bits = size of NACK_SN field + E1, E2 bits - // 42 bits = size of NACK_SN field + SO_START, SO_END fields, E1, E2 bits - while ((!status_report_completed) && (RLC_AM_DIFF_SN(sn_nack,rlc_pP->vr_r) < RLC_AM_DIFF_SN(rlc_pP->vr_ms,rlc_pP->vr_r)) - && (cursor_p != NULL) && (nb_bits_transmitted <= nb_bits_to_transmit)) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t *)(cursor_p->data))->pdu_info; - sn_cursor = pdu_info_cursor_p->sn; - all_segments_received = ((rlc_am_rx_pdu_management_t *)(cursor_p->data))->all_segments_received; - - /* First fill NACK_SN with each missing PDU between current sn_nack and sn_cursor */ - while ((sn_nack != sn_cursor) && (RLC_AM_DIFF_SN(sn_nack,rlc_pP->vr_r) < RLC_AM_DIFF_SN(rlc_pP->vr_ms,rlc_pP->vr_r))) { - if (nb_bits_transmitted + RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) <= nb_bits_to_transmit) { - /* Fill NACK_SN infos */ - control_pdu_info.nack_list[control_pdu_info.num_nack].nack_sn = sn_nack; - control_pdu_info.nack_list[control_pdu_info.num_nack].so_start = 0; - control_pdu_info.nack_list[control_pdu_info.num_nack].so_end = RLC_AM_STATUS_PDU_SO_END_ALL_BYTES; - control_pdu_info.nack_list[control_pdu_info.num_nack].e2 = 0; - /* Set E1 for next NACK_SN. The last one will be cleared */ - control_pdu_info.nack_list[control_pdu_info.num_nack].e1 = 1; - control_pdu_info.num_nack += 1; - nb_bits_transmitted += (RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1)); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING NACK %04d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - __LINE__, - sn_nack); - sn_nack = RLC_AM_NEXT_SN(sn_nack); - } else { - /* Not enough UL TBS*/ - /* latest value of sn_nack shall be used as ACK_SN */ - control_pdu_info.ack_sn = sn_nack; - status_report_completed = true; - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d NOT ENOUGH TBS STOP WITH ACK_SN %04d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - __LINE__, - sn_nack); - break; - } - } - - if (sn_nack == rlc_pP->vr_ms) { - break; - } - - /* Now process all Segments of sn_cursor if PDU not fully received */ - if ((!status_report_completed) && (all_segments_received == 0) && (sn_cursor != rlc_pP->vr_ms)) { - //AssertFatal (sn_nack == sn_cursor, "RLC AM Tx Status PDU Data sn_nack=%d and sn_cursor=%d should be equal LcId=%d\n",sn_nack,sn_cursor, rlc_pP->channel_id); - if(sn_nack != sn_cursor) { - LOG_E(RLC, "RLC AM Tx Status PDU Data sn_nack=%d and sn_cursor=%d should be equal LcId=%d\n",sn_nack,sn_cursor, rlc_pP->channel_id); - } - /* First ensure there is enough TBS for at least 1 SOStart/SOEnd, else break */ - else if ((nb_bits_transmitted + RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) + (RLC_AM_STATUS_PDU_SO_LENGTH << 1)) <= nb_bits_to_transmit) { - /* Init loop flags */ - /* Check lsf */ - segment_loop_end = (pdu_info_cursor_p->lsf == 1); - - /* Init first SO Start according to first segment */ - if (pdu_info_cursor_p->so) { - /* Fill the first SO */ - control_pdu_info.nack_list[control_pdu_info.num_nack].nack_sn = sn_cursor; - control_pdu_info.nack_list[control_pdu_info.num_nack].so_start = 0; - control_pdu_info.nack_list[control_pdu_info.num_nack].so_end = pdu_info_cursor_p->so - 1; - control_pdu_info.nack_list[control_pdu_info.num_nack].e2 = 1; - /* Set E1 for next NACK_SN. The last one will be cleared */ - control_pdu_info.nack_list[control_pdu_info.num_nack].e1 = 1; - control_pdu_info.num_nack += 1; - nb_bits_transmitted += (RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) + (RLC_AM_STATUS_PDU_SO_LENGTH << 1)); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING NACK %04d SO START %05d SO END %05d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - __LINE__, - sn_cursor, - 0, - pdu_info_cursor_p->so - 1); - waited_so = pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size; - } else { - waited_so = pdu_info_cursor_p->payload_size; - } - - /* Go to next segment */ - cursor_p = cursor_p->next; - - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t *)(cursor_p->data))->pdu_info; - } - - /* Find the first discontinuity and then fill SOStart/SOEnd */ - while (!segment_loop_end) { - if ((cursor_p != NULL) && (pdu_info_cursor_p->sn == sn_cursor)) { - /* PDU segment is for the same SN*/ - /* Check lsf */ - segment_loop_end = (pdu_info_cursor_p->lsf == 1); - - if (waited_so < pdu_info_cursor_p->so) { - /* SO is greater than previous received portion : gap identified to fill */ - if ((nb_bits_transmitted + RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) + (RLC_AM_STATUS_PDU_SO_LENGTH << 1)) <= nb_bits_to_transmit) { - control_pdu_info.nack_list[control_pdu_info.num_nack].nack_sn = sn_cursor; - control_pdu_info.nack_list[control_pdu_info.num_nack].so_start = waited_so; - control_pdu_info.nack_list[control_pdu_info.num_nack].so_end = pdu_info_cursor_p->so - 1; - control_pdu_info.nack_list[control_pdu_info.num_nack].e2 = 1; - /* Set E1 for next NACK_SN. The last one will be cleared */ - control_pdu_info.nack_list[control_pdu_info.num_nack].e1 = 1; - control_pdu_info.num_nack += 1; - nb_bits_transmitted += (RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) + (RLC_AM_STATUS_PDU_SO_LENGTH << 1)); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING NACK %04d SO START %05d SO END %05d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - __LINE__, - sn_cursor, - waited_so, - pdu_info_cursor_p->so); - } else { - /* Not enough resources to set a SOStart/SEnd, then set ACK_SN to current NACK_SN and stop Status PDU build */ - control_pdu_info.ack_sn = sn_cursor; - status_report_completed = true; - segment_loop_end = true; - break; - } - } else { - /* contiguous segment: only update waited_so */ - /* Assuming so and payload_size updated according to duplication removal done at reception ... */ - waited_so += pdu_info_cursor_p->payload_size; - } - - /* Go to next received PDU or PDU Segment */ - cursor_p = cursor_p->next; - - if (cursor_p != NULL) { - pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t *)(cursor_p->data))->pdu_info; - } - } //end if (cursor_p != NULL) && (pdu_info_cursor_p->sn == sn_cursor) - else { - /* Previous PDU segment was the last one and did not have lsf indication : fill the latest gap */ - if ((nb_bits_transmitted + RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) + (RLC_AM_STATUS_PDU_SO_LENGTH << 1)) <= nb_bits_to_transmit) { - control_pdu_info.nack_list[control_pdu_info.num_nack].nack_sn = sn_cursor; - control_pdu_info.nack_list[control_pdu_info.num_nack].so_start = waited_so; - control_pdu_info.nack_list[control_pdu_info.num_nack].so_end = RLC_AM_STATUS_PDU_SO_END_ALL_BYTES; - control_pdu_info.nack_list[control_pdu_info.num_nack].e2 = 1; - /* Set E1 for next NACK_SN. The last one will be cleared */ - control_pdu_info.nack_list[control_pdu_info.num_nack].e1 = 1; - control_pdu_info.num_nack += 1; - nb_bits_transmitted += (RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) + (RLC_AM_STATUS_PDU_SO_LENGTH << 1)); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING LAST NACK %04d SO START %05d SO END %05d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - __LINE__, - sn_cursor, - waited_so, - RLC_AM_STATUS_PDU_SO_END_ALL_BYTES); - } else { - /* Not enough resources to set a SOStart/SEnd, then set ACK_SN to current NACK_SN and stop Status PDU build */ - control_pdu_info.ack_sn = sn_cursor; - status_report_completed = true; - } - - segment_loop_end = true; - } - } //end while (!segment_loop_end) - } // end if enough resource for transmitting at least one SOStart/SOEnd - else { - /* Not enough UL TBS to set at least one SOStart/SOEnd */ - /* latest value of sn_nack shall be used as ACK_SN */ - control_pdu_info.ack_sn = sn_nack; - status_report_completed = true; - } - } // end while on all PDU segments of sn_cursor - else { - /* 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_cursor = vrMS and if current SN was not fully received */ - if (RLC_AM_DIFF_SN(sn_cursor,rlc_pP->vr_r) < RLC_AM_DIFF_SN(rlc_pP->vr_ms,rlc_pP->vr_r)) { - sn_nack = RLC_AM_NEXT_SN(sn_cursor); - } else { - sn_nack = rlc_pP->vr_ms; - } - } // 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 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) || (all_segments_received == 0))) { - LOG_E(RLC, "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); - return; - } - - 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) { - control_pdu_info.ack_sn = sn_nack; - } - } else { - /* reception buffer empty or not enough TBS for filling at least 1 NACK_SN + E1 + E2 */ - control_pdu_info.ack_sn = rlc_pP->vr_r; - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING ACK %04d = VR(R)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - __LINE__, - control_pdu_info.ack_sn); - } - - //msg ("[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] nb_bits_to_transmit %d\n", - // rlc_pP->module_id, rlc_pP->rb_id, ctxt_pP->frame,nb_bits_to_transmit); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d PREPARE SENDING ACK %04d NUM NACK %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - __LINE__, - control_pdu_info.ack_sn, - control_pdu_info.num_nack); - /* encode the control pdu */ - pdu_size = (nb_bits_transmitted + 7) >> 3; - - // AssertFatal (pdu_size <= rlc_pP->nb_bytes_requested_by_mac, "RLC AM Tx Status PDU Data size=%d bigger than remaining TBS=%d nb_bits_transmitted=%d LcId=%d\n", - // pdu_size,rlc_pP->nb_bytes_requested_by_mac,nb_bits_transmitted, rlc_pP->channel_id); - if(pdu_size > rlc_pP->nb_bytes_requested_by_mac) { - LOG_E(RLC, "RLC AM Tx Status PDU Data size=%d bigger than remaining TBS=%d nb_bits_transmitted=%d LcId=%d\n", - pdu_size,rlc_pP->nb_bytes_requested_by_mac,nb_bits_transmitted, rlc_pP->channel_id); - return; - } - - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] LINE %d forecast pdu_size %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - __LINE__, - pdu_size); - tb_p = get_free_mem_block(sizeof(struct mac_tb_req) + pdu_size, __func__); - - if(tb_p == NULL) return; - - memset(tb_p->data, 0, sizeof(struct mac_tb_req) + pdu_size); - //estimation only ((struct mac_tb_req*)(tb_p->data))->tb_size = pdu_size; - ((struct mac_tb_req *)(tb_p->data))->data_ptr = (uint8_t *)&(tb_p->data[sizeof(struct mac_tb_req)]); - // warning reuse of pdu_size - // TODO : rlc_am_write_status_pdu should be rewritten as not very tested ... - pdu_size = rlc_am_write_status_pdu(ctxt_pP, rlc_pP,(rlc_am_pdu_sn_10_t *)(((struct mac_tb_req *)(tb_p->data))->data_ptr), &control_pdu_info); - ((struct mac_tb_req *)(tb_p->data))->tb_size = pdu_size; - //assert((((struct mac_tb_req*)(tb_p->data))->tb_size) < 3000); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEND-STATUS] SEND STATUS PDU SIZE %d, rlc_pP->nb_bytes_requested_by_mac %d, nb_bits_to_transmit>>3 %d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_size, - rlc_pP->nb_bytes_requested_by_mac, - nb_bits_to_transmit >> 3); - - // AssertFatal (pdu_size == ((nb_bits_transmitted + 7) >> 3), "RLC AM Tx Status PDU Data encoding size=%d different than expected=%d LcId=%d\n", - // pdu_size,((nb_bits_transmitted + 7) >> 3), rlc_pP->channel_id); - if(pdu_size != ((nb_bits_transmitted + 7) >> 3)) { - LOG_E(RLC, "RLC AM Tx Status PDU Data encoding size=%d different than expected=%d LcId=%d\n", - pdu_size,((nb_bits_transmitted + 7) >> 3), rlc_pP->channel_id); - pdu_size = 0; - return; - } - - // remaining bytes to transmit for RLC (retrans pdus and new data pdus) - rlc_pP->nb_bytes_requested_by_mac = rlc_pP->nb_bytes_requested_by_mac - pdu_size; - // put pdu in trans - list_add_head(tb_p, &rlc_pP->control_pdu_list); - rlc_pP->stat_tx_control_pdu += 1; - rlc_pP->stat_tx_control_bytes += pdu_size; -} - - diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h deleted file mode 100644 index 861e15212383e5a9382e285061517713a11db1c0..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_status_report.h -* \brief This file defines the prototypes of the functions dealing with the reading/writting of informations from/in RLC AM control PDUs, and the processing of received control PDUs. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_status_report_impl_ RLC AM Status Report Reference Implementation -* @ingroup _rlc_am_internal_impl_ -* @{ -*/ -#ifndef __RLC_AM_STATUS_REPORT_H__ -# define __RLC_AM_STATUS_REPORT_H__ - -# include "UTIL/MEM/mem_block.h" -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -#include "platform_types.h" -#include "common/platform_constants.h" -//#include "PHY/defs.h" - -//----------------------------------------------------------------------------- -/*! \fn uint16_t rlc_am_read_bit_field (uint8_t** dataP, unsigned int* bit_posP, const signed int bits_to_readP) -* \brief Read N bits in a byte area seen as a bit-field with the help of a byte index and a modulo 8 bit index. -* \param[in,out] dataP Data pointer on area to read, updated after the read. -* \param[in,out] bit_posP Last ending read bit position, updated after the read. -* \param[in] bits_to_readP Number of bits to read (max 16). -* \return Value read on 16 bits, bits read are shifted to least significant bits of returned short value. -*/ -uint16_t rlc_am_read_bit_field (uint8_t** dataP, unsigned int* bit_posP, const signed int bits_to_readP); - -/*! \fn void rlc_am_write8_bit_field(uint8_t** dataP, unsigned int* bit_posP, signed int bits_to_writeP, const uint8_t valueP) -* \brief Write N bits (max 8) in a byte area seen as a bit-field with the help of a byte index and a modulo 8 bit index. -* \param[in,out] dataP Data pointer on area to write, updated after the write. -* \param[in,out] bit_posP Last ending read write position, updated after the write. -* \param[in] bits_to_writeP Number of bits to write (max 8). -* \param[in] valueP Value to write. -*/ -void rlc_am_write8_bit_field(uint8_t** dataP, unsigned int* bit_posP, signed int bits_to_writeP, const uint8_t valueP); - -/*! \fn void rlc_am_write16_bit_field(uint8_t** dataP, unsigned int* bit_posP, signed int bits_to_writeP, const uint16_t valueP) -* \brief Write N bits (max 16) in a byte area seen as a bit-field with the help of a byte index and a modulo 8 bit index. -* \param[in,out] dataP Data pointer on area to write, updated after the write. -* \param[in,out] bit_posP Last ending read write position, updated after the write. -* \param[in] bits_to_writeP Number of bits to write (max 16). -* \param[in] valueP Value to write. -*/ -void rlc_am_write16_bit_field( - uint8_t** dataP, - unsigned int* bit_posP, - signed int bits_to_writeP, - const uint16_t valueP); - -/*! \fn signed int rlc_am_get_control_pdu_infos (rlc_am_pdu_sn_10_t* const headerP, sdu_size_t * const total_sizeP, rlc_am_control_pdu_info_t* const pdu_infoP) -* \brief Retrieve control PDU informations from a serialized control PDU. -* \param[in] headerP Pointer on the header of the RLC AM PDU. -* \param[in] total_size_pP Pointer on PDU size in bytes. -* \param[in,out] pdu_infoP Struct containing interpreted PDU control informations. -*/ -signed int rlc_am_get_control_pdu_infos ( - rlc_am_pdu_sn_10_t* const headerP, - sdu_size_t * const total_size_pP, - rlc_am_control_pdu_info_t* const pdu_infoP); - -/*! \fn void rlc_am_display_control_pdu_infos(const rlc_am_control_pdu_info_t* const pdu_infoP) -* \brief Dump on LOG output the informations contained in the pdu_infoP structure. -* \param[in] pdu_infoP Struct containing interpreted PDU control informations. -*/ -void rlc_am_display_control_pdu_infos(const rlc_am_control_pdu_info_t* const pdu_infoP); - -/*! \fn void rlc_am_receive_process_control_pdu(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP, mem_block_t* const tbP, uint8_t* first_byte, const uint16_t tb_size_in_bytes) -* \brief Process the informations contained in the control PDU. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] tbP Control PDU embedded in a mem_block_t structure. -* \param[in] first_byte Pointer on first byte of control PDU. -* \param[in] tb_size_in_bytes Pointer on size of serialized control PDU in bytes. -*/ -void rlc_am_receive_process_control_pdu( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP, - mem_block_t* const tbP, - uint8_t** first_byte, - sdu_size_t * const tb_size_in_bytes); - -/*! \fn int rlc_am_write_status_pdu(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP, rlc_am_pdu_sn_10_t* const rlc_am_pdu_sn_10P, rlc_am_control_pdu_info_t* const pdu_infoP) -* \brief Remove all marked holes for PDU with sequence number "snP". -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] rlc_am_pdu_sn_10P Pointer on the header of the RLC AM control PDU. -* \param[in] pdu_infoP Struct containing PDU control informations elements. -* \return The number of bytes that have been written. -*/ -int rlc_am_write_status_pdu( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - rlc_am_pdu_sn_10_t* const rlc_am_pdu_sn_10P, - rlc_am_control_pdu_info_t* const pdu_infoP); - -/*! \fn void rlc_am_send_status_pdu(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP) -* \brief Send a status PDU based on the receiver buffer content. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void rlc_am_send_status_pdu( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP); -/** @} */ -#endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h deleted file mode 100644 index cc2e3b9c1b9ba5eb7270e5e144c1d33c92d3b8e3..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_structs.h -* \brief This file defines structures used inside the RLC AM. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -# ifndef __RLC_AM_STRUCTS_H__ -# define __RLC_AM_STRUCTS_H__ - -# include "platform_types.h" -#include "common/platform_constants.h" -# include "list.h" -# include "mem_block.h" -# include "rlc_am_constants.h" -# include "mac_rlc_primitives.h" -# include "mac_primitives.h" -# include "rlc_primitives.h" -/** -* @addtogroup _rlc_am_internal_input_sdu_impl_ -* @{ -*/ -//----------------------------------------------------------------------------- -// SDU MANAGEMENT -//----------------------------------------------------------------------------- -/*! \struct sdu_management_flags_t -* \brief Structure containing SDU bit-field flags (for memory optimization purpose) related to its segmentation and transmission. -*/ -typedef struct sdu_management_flags { - uint8_t discarded:1; /*!< \brief Boolean telling if this SDU is discarded, actually unused. */ - uint8_t segmented:1; /*!< \brief Boolean telling if the segmentation of this SDU is completed, actually unused. */ - uint8_t segmentation_in_progress:1; /*!< \brief Boolean telling if the segmentation of this SDU is started but not completed, actually unused. */ - uint8_t no_new_sdu_segmented_in_last_pdu:1; /*!< \brief Actually unused. */ - uint8_t transmitted_successfully:1; /*!< \brief SDU acknowledged by peer RLC AM. */ - uint8_t dummy:3; /*!< \brief Free bits. */ -} sdu_management_flags_t; - -/*! \struct rlc_am_tx_sdu_management_t -* \brief Structure containing SDU variables related to its segmentation and transmission. -*/ -typedef struct rlc_am_tx_sdu_management { - mem_block_t *mem_block; /*!< \brief SDU embedded in a mem_block_t. */ - uint8_t *first_byte; /*!< \brief Pointer on SDU payload. */ - frame_t sdu_creation_time; /*!< \brief Time stamped with mac_xface->frame. */ - mui_t mui; /*!< \brief Message Unit Identifier, still here for historical reasons (no LTE-PDCP compliant now). */ - sdu_size_t sdu_remaining_size; /*!< \brief Remaining size in bytes to be filled in a PDU. */ - sdu_size_t sdu_segmented_size; /*!< \brief Bytes already segmented in a/several PDU(s). */ - sdu_size_t sdu_size; /*!< \brief SDU size in bytes. */ - int16_t pdus_index[RLC_AM_MAX_SDU_FRAGMENTS]; /*!< \brief Array containing the sequence numbers of the PDU in which the SDU has been segmented. */ - uint8_t nb_pdus; /*!< \brief Number of referenced PDUs in pdus_index[] array. */ - uint8_t nb_pdus_ack; /*!< \brief Number of referenced PDUs in pdus_index[] array that have been acknowledged. (used for confirmation and MaxDat discard)*/ - sdu_management_flags_t flags; /*!< \brief bit-field flags related to SDU segmentation and transmission */ -} rlc_am_tx_sdu_management_t; - -/** @} */ - -/** -* @addtogroup _rlc_am_internal_retransmit_impl_ -* @{ -*/ - -/*! \struct pdu_management_flags_t -* \brief Structure containing PDU variables related to its retransmission. -*/ -typedef struct pdu_management_flags { - uint8_t transmitted:1; /*!< \brief Boolean telling that this PDU is not empty and has been at least transmitted once. */ - uint8_t ack:1; /*!< \brief Boolean telling that this PDU has been acknowledged. */ - uint8_t nack:1; /*!< \brief Boolean telling that this PDU has been acknowledged negatively. */ - uint8_t retransmit:1; /*!< \brief Boolean telling a retransmission is scheduled for this PDU. */ - uint8_t max_retransmit:1; /*!< \brief Boolean telling max retransmission has been hit for this PDU. */ - uint8_t dummy:3; /*!< \brief Free bits. */ -} pdu_management_flags_t; - - - -/*! \struct rlc_am_tx_data_pdu_management_t -* \brief Structure containing PDU variables related to its acknowlegment, non acknowlegment, resegmentation and retransmission. -*/ -typedef struct rlc_am_tx_data_pdu_management { - mem_block_t *mem_block; /*!< \brief PDU embedded in a mem_block_t struct */ - uint8_t *first_byte; /*!< \brief Pointer on the PDU including header, LIs, data */ - uint8_t *payload; /*!< \brief Pointer on the PDU payload */ - int16_t sdus_index[RLC_AM_MAX_SDU_IN_PDU]; /*!< \brief Index of SDU(s) having segments in this pdu (index in rlc_am_entity.input_sdus[]) */ - frame_t last_nack_time; /*!< \brief Last frame this PDU was negative acknowledged, for not nacking several times in the same frame */ - sdu_size_t hole_so_start [RLC_AM_MAX_HOLES_REPORT_PER_PDU]; /*!< \brief Array containing the start segment offsets for marking a hole (negative acknowledged area) in the PDU. */ - sdu_size_t hole_so_stop [RLC_AM_MAX_HOLES_REPORT_PER_PDU]; /*!< \brief Array containing the stop segment offsets for marking a hole (negative acknowledged area) in the PDU. */ - uint8_t num_holes; /*!< \brief Number of registereg holes in hole_so_start[], hole_so_stop[]. */ - uint8_t retx_hole_index; /*!< \brief Next index of registered holes to retransmit. */ - sdu_size_t header_and_payload_size; /*!< \brief Size of the PDU in bytes, including header and payload. */ - sdu_size_t payload_size; /*!< \brief Size of the PDU payload in bytes. */ - sdu_size_t retx_payload_size; /*!< \brief Size of the PDU payload to be retransmitted in bytes including all Segment portions. */ - rlc_sn_t sn; /*!< \brief Sequence number of the PDU. */ - sdu_size_t nack_so_start; /*!< \brief Lowest NACK start segment offset, must be set to 0 if global NACK. */ - sdu_size_t nack_so_stop; /*!< \brief Highest NACK stop segment offset, must be set to data_size - 1 if global NACK */ - - int8_t nb_sdus; /*!< \brief Number of sdu having segments in this pdu. */ - int8_t retx_count; /*!< \brief Counts the number of already occurred retransmissions of an AMD PDU (see subclause 5.2.1). */ - int8_t retx_count_next; /*!< \brief Counts the number of already occurred retransmissions plus the latest pending one. */ - - pdu_management_flags_t flags; /*!< \brief PDU variables related to its retransmission. */ -} rlc_am_tx_data_pdu_management_t; - -/** @} */ - -/** -* @addtogroup _rlc_am_status_report_impl_ -* @{ -*/ - -/*! \struct nack_sn_t -* \brief Structure containing Status PDU information element. -*/ -typedef struct nack_sn { - uint16_t nack_sn:10; /*!< \brief NACK sequence number field. */ - uint16_t e1:1; /*!< \brief Extension bit 1 field. */ - uint16_t e2:1; /*!< \brief Extension bit 2 field. */ - uint32_t so_start:15; /*!< \brief Optional SOstart field (depending on e2 bit). */ - uint32_t so_end:15; /*!< \brief Optional SOend field (depending on e2 bit). */ -} nack_sn_t; - -/*! \struct rlc_am_control_pdu_info_t -* \brief Structure containing Status PDU information element. -*/ -typedef struct rlc_am_control_pdu_info { - uint16_t d_c:1; /*!< \brief Data/Control field. */ - uint16_t cpt:3; /*!< \brief Control PDU type. */ - uint16_t ack_sn:10; /*!< \brief Acknowledgment SN field. */ - uint16_t e1:1; /*!< \brief Extension bit 1 field. */ - uint16_t dummy:2; /*!< \brief Unused bits. */ - uint16_t num_nack; /*!< \brief Number of nack_sn_t fields in nack_list[]. */ - nack_sn_t nack_list[RLC_AM_MAX_NACK_IN_STATUS_PDU]; /*!< \brief List of NACK_SN fields. */ -} rlc_am_control_pdu_info_t ; - -/*! \struct rlc_am_e_li_t -* \brief Structure helping coding and decoding LI and e bits in AMD PDUs and AMD PDU segments. -*/ -typedef struct rlc_am_e_li { - uint8_t b1; /*!< \brief 1st byte. */ - uint8_t b2; /*!< \brief 2nd byte. */ - uint8_t b3; /*!< \brief 3rd byte. */ -} rlc_am_e_li_t; - -/** @} */ - -/** -* @addtogroup _rlc_am_internal_impl_ -* @{ -*/ -/*! \struct rlc_am_pdu_sn_10_t -* \brief Structure helping coding and decoding the first 2 bytes of a AMD PDU or AMD PDU segment. -*/ -typedef struct rlc_am_pdu_sn_10 { - uint8_t b1; /*!< \brief 1st byte. */ - uint8_t b2; /*!< \brief 2nd byte. */ - uint8_t data[2];/*!< \brief Following bytes. */ -} __attribute__((__packed__)) rlc_am_pdu_sn_10_t ; -/** @} */ - - -/** -* @addtogroup _rlc_am_internal_receiver_impl_ -* @{ -*/ -/*! \struct rlc_am_pdu_info_t -* \brief Structure for storing decoded informations from the header of a AMD PDU or AMD PDU segment. -*/ -typedef struct rlc_am_pdu_info { - uint32_t d_c:1; /*!< \brief Data/Control field. */ - uint32_t rf:1; /*!< \brief Resegmentation Flag field. */ - uint32_t p:1; /*!< \brief Polling bit field. */ - uint32_t fi:2; /*!< \brief Framing Info field. */ - uint32_t e:1; /*!< \brief Extension bit field. */ - uint32_t sn:10; /*!< \brief Sequence Number field. */ - uint32_t lsf:1; /*!< \brief Last Segment Flag field. */ - uint32_t so:15; /*!< \brief Segment Offset field. */ - uint16_t num_li; /*!< \brief Number of Length Indicators. */ - int16_t li_list[RLC_AM_MAX_SDU_IN_PDU]; /*!< \brief List of Length Indicators. */ - int16_t hidden_size /*!< \brief Part of payload size in bytes that is not included in the sum of LI fields. */; - uint8_t* payload; /*!< \brief Pointer on PDU payload. */ - int16_t payload_size;/*!< \brief Size of payload in bytes. */ - int16_t header_size; /*!< \brief Size of header in bytes (including SO field and LI fields). */ -} rlc_am_pdu_info_t ; -/** @} */ - - -/** -* @addtogroup _rlc_am_timers_impl_ -* @{ -*/ -/*! \struct rlc_am_timer_t -* \brief Generic structure for implementing a timer. -*/ -typedef struct rlc_am_timer { - uint32_t ms_time_out; /*!< \brief When set, indicate the time in milliseconds the timer will time-out. */ - uint32_t ms_start; /*!< \brief indicate the time in milliseconds the timer has been started. */ - uint32_t ms_duration; /*!< \brief Configured timer duration in milliseconds. */ - uint32_t running:1; /*!< \brief The timer is running. */ - uint32_t timed_out:1; /*!< \brief The timer has timed-out. */ - uint32_t dummy:30; /*!< \brief Bits not used. */ -} rlc_am_timer_t ; -/** @} */ - -//----------------------------------------------------------------------------- -// DATA PDU -//----------------------------------------------------------------------------- -/** -* @addtogroup _rlc_am_internal_receiver_impl_ -* @{ -*/ - -typedef enum rlc_am_rx_segment_reassemble_info -{ - /** No Reassembly scheduled */ - RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_NO = 0, - /** Reassembly scheduled */ - RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_PENDING = 1, - /** Reassembly done */ - RLC_AM_RX_PDU_SEGMENT_REASSEMBLED = 2 - -} rlc_am_rx_segment_reassemble_info_t; - -/*! \struct rlc_am_rx_pdu_management_t -* \brief Structure for storing decoded informations from the header of a AMD PDU or AMD PDU segment and information on reassembly. -*/ -typedef struct rlc_am_rx_pdu_management { - rlc_am_pdu_info_t pdu_info; /*!< \brief Field for storing decoded informations from the header of a AMD PDU or AMD PDU segment. */ - uint8_t all_segments_received; /*!< \brief Is all segments of PDU SN have been received. */ - rlc_am_rx_segment_reassemble_info_t segment_reassembled; /*!< \brief if the segment for SN=vrR is reassembled but not discarded yet. */ -} rlc_am_rx_pdu_management_t; -/** @} */ - -typedef enum rlc_am_rx_pdu_status -{ - /** PDU okay. */ - RLC_AM_DATA_PDU_STATUS_OK = 0, - /** SN outside RX window */ - RLC_AM_DATA_PDU_STATUS_SN_OUTSIDE_WINDOW = 1, - /** SN already available */ - RLC_AM_DATA_PDU_STATUS_SN_DUPLICATE = 2, - /** SN already available */ - RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE = 3, - /** Buffer full */ - RLC_AM_DATA_PDU_STATUS_BUFFER_FULL = 4, - /** Header Error (LI,SO...) */ - RLC_AM_DATA_PDU_STATUS_HEADER_ERROR = 5, - /** Unknown bearer */ - RLC_AM_DATA_PDU_STATUS_INVALID_BEARER = 6, - /** RLC in wrong state */ - RLC_AM_DATA_PDU_STATUS_WRONG_STATE = 7 - -} rlc_am_rx_pdu_status_t; - -/*! \cond PRIVATE */ -//----------------------------------------------------------------------------- -// interlayers optimizations -//----------------------------------------------------------------------------- -struct rlc_am_tx_data_pdu_allocation { - union { - struct rlc_am_tx_data_pdu_management rlc_am_tx_pdu_mngmnt; - struct mac_tb_req tb_req; - struct mac_tx_tb_management tb_mngt; - } dummy; -}; - -/*struct rlc_am_tx_control_pdu_allocation { - union { - struct mac_tb_req tb_req; - struct mac_tx_tb_management tb_mngt; - } dummy; -};*/ - -struct rlc_am_data_req_alloc { // alloc enought bytes for sdu mngt also - union { - struct rlc_am_data_req dummy1; - struct rlc_am_tx_sdu_management dummy2; - } dummy; -}; -/*! \endcond */ -# endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c deleted file mode 100644 index e898a601c2c7759ac41a12fffd947e4556d29b33..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c +++ /dev/null @@ -1,1183 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_TEST_C 1 -#define RLC_C 1 - -#include <execinfo.h> -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include <string.h> -#include <assert.h> -#include <signal.h> -#include <sys/time.h> - - -#include "platform_types.h" -//----------------------------------------------------------------------------- -#include "rlc.h" -#include "rlc_am.h" -#include "rlc_am_test.h" -#include "list.h" -#include "LAYER2/MAC/extern.h" - - - - - - - - -#define TEST1 -#define TEST2 -#define TEST3 -#define TEST4 -#define TEST5 -#define TEST6 -#define TEST7 - -#define TEST_MAX_SEND_SDU 8192 -#define TARGET_MAX_RX_ERROR_RATE 10 -#define TARGET_MAX_TX_ERROR_RATE 10 -static int g_frame = 0; -static int g_random_sdu; -static int g_random_nb_frames; -static int g_random_tx_pdu_size; -static int g_random_rx_pdu_size; -static int g_target_tx_error_rate; -static int g_target_rx_error_rate; -static int g_tx_packets = 0; -static int g_dropped_tx_packets = 0; -static int g_rx_packets = 0; -static int g_dropped_rx_packets = 0; -static int g_drop_rx = 0; -static int g_drop_tx = 0; -static int g_mui = 0; -static int g_send_sdu_ids[TEST_MAX_SEND_SDU][2]; -static int g_send_id_write_index[2]; -static int g_send_id_read_index[2]; -static uint8_t g_buffer[32]; -static int8_t *g_sdus[] = {"En dépit de son volontarisme affiché, le premier ministre est de plus en plus décrié pour son incompétence. La tension politique et dans l'opinion publique est encore montée d'un cran au Japon, sur fond d'inquiétantes nouvelles, avec du plutonium détecté dans le sol autour de la centrale de Fukushima. Le premier ministre Naoto Kan a solennellement déclaré que son gouvernement était «en état d'alerte maximum». Tout en reconnaissant que la situation restait «imprévisible». Ce volontarisme affiché par le premier ministre - que Nicolas Sarkozy rencontrera demain lors d'une visite au Japon - ne l'a pas empêché d'être la cible de violentes critiques de la part de parlementaires sur sa gestion de la crise. Attaqué sur le manque de transparence, il a assuré qu'il rendait publiques toutes les informations en sa possession. Un député de l'opposition, Yosuke Isozaki, a aussi reproché à Naoto Kan de ne pas avoir ordonné l'évacuation des populations dans la zone comprise entre 20 et 30 km autour de la centrale. «Peut-il y avoir quelque chose de plus irresponsable que cela ?», a-t-il lancé. Pour l'heure, la zone d'évacuation est limitée à un rayon de 20 km, seul le confinement étant recommandé pour les 10 km suivants. Sur ce sujet, les autorités japonaises ont été fragilisées mardi par les déclarations de Greenpeace, affirmant que ses experts avaient détecté une radioactivité dangereuse à 40 km de la centrale. L'organisation écologiste a appelé à une extension de la zone d'évacuation, exhortant Tokyo à «cesser de privilégier la politique aux dépens de la science». L'Agence japonaise de sûreté nucléaire a balayé ces critiques.", - - "La pâquerette (Bellis perennis) est une plante vivace des prés, des pelouses, des bords de chemins et des prairies, haute de dix à vingt centimètres, de la famille des Astéracées, dont les fleurs naissent sur des inflorescences appelées capitules : celles du pourtour, que l'on croit à tort être des pétales, appelées fleurs ligulées, parce qu'elles ont la forme d'une languette, ou demi-fleurons, sont des fleurs femelles, dont la couleur varie du blanc au rose plus ou moins prononcé ; celles du centre, jaunes, appelées fleurs tubuleuses, parce que leur corolle forme un tube, ou fleurons, sont hermaphrodites. Ainsi, contrairement à l'opinion populaire, ce qu'on appelle une « fleur » de pâquerette n'est en réalité pas « une » fleur mais un capitule portant des fleurs très nombreuses.Leurs fruits s'envolent grâce au vent et dégagent des odeurs qui attirent les insectes.Une variété muricole peut pousser sur des murs humides verticaux.Les pâquerettes sont des fleurs rustiques et très communes en Europe, sur les gazons, les prairies, les chemins et les zones d'herbe rase.Elles ont la particularité, comme certaines autres fleurs de plantes herbacées, de se fermer la nuit et de s'ouvrir le matin pour s'épanouir au soleil ; elles peuvent aussi se fermer pendant les averses, voire un peu avant, ce qui permet dans les campagnes de prédire la pluie légèrement à l'avance.", - - "La pâquerette", - " (Bellis perennis)", - " est une plante vivace des prés,", - " des pelouses,", - " des bords de chemins et des prairies,", - "haute de dix à ", - " vingt centimètres", - ", de la", - " famille des", - " Astéracées", - ", dont", - " les", - " fleurs", - " naissent", - " sur", - " des", - " inflorescences", - " appelées", - " capitules", - " : celles", - " du pourtour", - ", que l'on", - " croit à ", - " tort", - " être", - " des pétales", - ", appelées", - " fleurs ligulées", - ", parce qu'elles", - " ont la forme d'une languette, ou demi-fleurons, sont", - " des fleurs femelles,", - " dont la couleur varie du blanc au rose plus ou moins prononcé ; celles du centre, jaunes,", - " appelées ", - "fleurs tubuleuses", - ", parce que leur corolle forme un tube, ou fleurons, sont hermaphrodites." - }; - -/* Returns the x-y size of the terminal */ - -//----------------------------------------------------------------------------- -void rlc_am_v9_3_0_test_windows() -//----------------------------------------------------------------------------- -{ - rlc_am_entity_t am1; - rlc_am_entity_t am2; - unsigned int i; - unsigned int j; - memset(am1,0,sizeof(rlc_am_entity_t)); - memset(am2,0,sizeof(rlc_am_entity_t)); - - rlc_am_init(&am1, g_frame); - rlc_am_init(&am2, g_frame); - - // TX window with vt_ms > vt_a - for (j = 0; j < RLC_AM_SN_MODULO-RLC_AM_WINDOW_SIZE; j++) { - am1.vt_a = j; - am1.vt_s = j; - am1.vt_ms = (am1.vt_a + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; - - for (i = 0 ; i < am1.vt_a; i ++) { - assert(rlc_am_in_tx_window(&am1, i) == 0); - } - - for (i = j ; i < am1.vt_ms; i ++) { - assert(rlc_am_in_tx_window(&am1, i) > 0); - } - - for (i = am1.vt_ms ; i <= 0xFFFF; i ++) { - //printf("assert(rlc_am_in_tx_window(&am1, %d) == 0)) vt(s)=%d vt(ms)=%d\n", i, am1.vt_s, am1.vt_ms); - assert(rlc_am_in_tx_window(&am1, i) == 0); - } - } - - // TX window with vt_ms < vt_a - for (j = RLC_AM_SN_MODULO-RLC_AM_WINDOW_SIZE; j < RLC_AM_SN_MODULO; j++) { - am1.vt_a = j; - am1.vt_s = j; - am1.vt_ms = (am1.vt_a + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; - - for (i = 0 ; i < am1.vt_ms; i ++) { - assert(rlc_am_in_tx_window(&am1, i) > 0); - } - - for (i = j ; i < am1.vt_a; i ++) { - assert(rlc_am_in_tx_window(&am1, i) == 0); - } - - for (i = am1.vt_a ; i < RLC_AM_SN_MODULO; i ++) { - assert(rlc_am_in_tx_window(&am1, i) > 0); - } - - for (i = RLC_AM_SN_MODULO ; i < 0xFFFF; i ++) { - assert(rlc_am_in_tx_window(&am1, i) == 0); - } - } - - // RX window with vr_mr > vr_r - for (j = 0; j < RLC_AM_SN_MODULO-RLC_AM_WINDOW_SIZE; j++) { - am1.vr_r = j; - am1.vr_mr = (am1.vr_r + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; - - for (i = 0 ; i < am1.vr_r; i ++) { - assert(rlc_am_in_rx_window(&am1, i) == 0); - } - - for (i = j ; i < am1.vr_mr; i ++) { - //printf("assert(rlc_am_in_rx_window(&am1, %d) == 0)) vr(r)=%d vr(mr)=%d\n", i, am1.vr_r, am1.vr_mr); - assert(rlc_am_in_rx_window(&am1, i) > 0); - } - - for (i = am1.vr_mr ; i <= 0xFFFF; i ++) { - assert(rlc_am_in_rx_window(&am1, i) == 0); - } - } - - // RX window with vr_mr < vr_r - for (j = RLC_AM_SN_MODULO-RLC_AM_WINDOW_SIZE; j < RLC_AM_SN_MODULO; j++) { - am1.vr_r = j; - am1.vr_mr = (am1.vr_r + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; - - for (i = 0 ; i < am1.vr_mr; i ++) { - assert(rlc_am_in_rx_window(&am1, i) > 0); - } - - for (i = j ; i < am1.vr_r; i ++) { - assert(rlc_am_in_rx_window(&am1, i) == 0); - } - - for (i = am1.vr_r ; i < RLC_AM_SN_MODULO; i ++) { - assert(rlc_am_in_rx_window(&am1, i) > 0); - } - - for (i = RLC_AM_SN_MODULO ; i < 0xFFFF; i ++) { - assert(rlc_am_in_rx_window(&am1, i) == 0); - } - } -} -//----------------------------------------------------------------------------- -void rlc_am_v9_3_0_test_read_write_bit_field() -//----------------------------------------------------------------------------- -{ - unsigned int bit_pos_write = 0; // range from 0 (MSB/left) to 7 (LSB/right) - uint8_t *byte_pos_write = g_buffer; - unsigned int bit_pos_read = 0; // range from 0 (MSB/left) to 7 (LSB/right) - uint8_t *byte_pos_read = g_buffer; - uint16_t read_value; - memset (g_buffer, 0, sizeof(g_buffer)); - // byte 0 - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 1); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 1); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 1); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 1); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - assert(g_buffer[0] == 0x96); - assert(g_buffer[1] == 0x00); - // byte 1 - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 1); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 1); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 1); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 1); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 1); - assert(g_buffer[0] == 0x96); - assert(g_buffer[1] == 0xD9); - assert(g_buffer[2] == 0x00); - // byte 2 - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 1); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 1); - assert(g_buffer[0] == 0x96); - assert(g_buffer[1] == 0xD9); - assert(g_buffer[2] == 0x11); - assert(g_buffer[3] == 0x00); - // byte 3 & 4 - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 2, 0x2); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 2, 0x1); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 2, 0x2); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0x0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 2, 0x3); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0x0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 2, 0x2); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 2, 0x1); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 2, 0x3); - assert(g_buffer[0] == 0x96); - assert(g_buffer[1] == 0xD9); - assert(g_buffer[2] == 0x11); - assert(g_buffer[3] == 0x99); - assert(g_buffer[4] == 0xA7); - assert(g_buffer[5] == 0x00); - // byte 5 & 6 - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 3, 0x7); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 3, 0x5); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 3, 0x1); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 3, 0x0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 3, 0x3); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0x0); - assert(g_buffer[0] == 0x96); - assert(g_buffer[1] == 0xD9); - assert(g_buffer[2] == 0x11); - assert(g_buffer[3] == 0x99); - assert(g_buffer[4] == 0xA7); - assert(g_buffer[5] == 0xF4); - assert(g_buffer[6] == 0x86); - assert(g_buffer[7] == 0x00); - // byte 7 & 8 & 9 - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 4, 0xC); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 4, 0xD); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 1, 0x0); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 4, 0xF); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 4, 0xA); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 4, 0xB); - rlc_am_write8_bit_field(&byte_pos_write, &bit_pos_write, 3, 0x0); - assert(g_buffer[0] == 0x96); - assert(g_buffer[1] == 0xD9); - assert(g_buffer[2] == 0x11); - assert(g_buffer[3] == 0x99); - assert(g_buffer[4] == 0xA7); - assert(g_buffer[5] == 0xF4); - assert(g_buffer[6] == 0x86); - assert(g_buffer[7] == 0xCD); - assert(g_buffer[8] == 0x7D); - assert(g_buffer[9] == 0x58); - assert(g_buffer[10] == 0x00); - // byte 10 & 11 & 12 & 13 & 14 - rlc_am_write16_bit_field(&byte_pos_write, &bit_pos_write, 10, 0x2AB); - rlc_am_write16_bit_field(&byte_pos_write, &bit_pos_write, 10, 0x1BA); - rlc_am_write16_bit_field(&byte_pos_write, &bit_pos_write, 10, 0x2AF); - rlc_am_write16_bit_field(&byte_pos_write, &bit_pos_write, 10, 0x134); - assert(g_buffer[0] == 0x96); - assert(g_buffer[1] == 0xD9); - assert(g_buffer[2] == 0x11); - assert(g_buffer[3] == 0x99); - assert(g_buffer[4] == 0xA7); - assert(g_buffer[5] == 0xF4); - assert(g_buffer[6] == 0x86); - assert(g_buffer[7] == 0xCD); - assert(g_buffer[8] == 0x7D); - assert(g_buffer[9] == 0x58); - assert(g_buffer[10] == 0xAA); - assert(g_buffer[11] == 0xDB); - assert(g_buffer[12] == 0xAA); - assert(g_buffer[13] == 0xBD); - assert(g_buffer[14] == 0x34); - assert(g_buffer[15] == 0x00); - // byte 15 - 29 - rlc_am_write16_bit_field(&byte_pos_write, &bit_pos_write, 15, 0x701F); - rlc_am_write16_bit_field(&byte_pos_write, &bit_pos_write, 15, 0x612E); - rlc_am_write16_bit_field(&byte_pos_write, &bit_pos_write, 15, 0x523D); - rlc_am_write16_bit_field(&byte_pos_write, &bit_pos_write, 15, 0x434C); - rlc_am_write16_bit_field(&byte_pos_write, &bit_pos_write, 15, 0x345B); - rlc_am_write16_bit_field(&byte_pos_write, &bit_pos_write, 15, 0x256A); - rlc_am_write16_bit_field(&byte_pos_write, &bit_pos_write, 15, 0x1679); - rlc_am_write16_bit_field(&byte_pos_write, &bit_pos_write, 15, 0x0788); - assert(g_buffer[0] == 0x96); - assert(g_buffer[1] == 0xD9); - assert(g_buffer[2] == 0x11); - assert(g_buffer[3] == 0x99); - assert(g_buffer[4] == 0xA7); - assert(g_buffer[5] == 0xF4); - assert(g_buffer[6] == 0x86); - assert(g_buffer[7] == 0xCD); - assert(g_buffer[8] == 0x7D); - assert(g_buffer[9] == 0x58); - assert(g_buffer[10] == 0xAA); - assert(g_buffer[11] == 0xDB); - assert(g_buffer[12] == 0xAA); - assert(g_buffer[13] == 0xBD); - assert(g_buffer[14] == 0x34); - assert(g_buffer[15] == 0xE0); - assert(g_buffer[16] == 0x3F); - assert(g_buffer[17] == 0x84); - assert(g_buffer[18] == 0xBA); - assert(g_buffer[19] == 0x91); - assert(g_buffer[20] == 0xEC); - assert(g_buffer[21] == 0x34); - assert(g_buffer[22] == 0xC6); - assert(g_buffer[23] == 0x8B); - assert(g_buffer[24] == 0x69); - assert(g_buffer[25] == 0x5A); - assert(g_buffer[26] == 0x8B); - assert(g_buffer[27] == 0x3C); - assert(g_buffer[28] == 0x87); - assert(g_buffer[29] == 0x88); - assert(g_buffer[30] == 0x00); - // 0x96 0xD9 - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b0 - assert(read_value == 1); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b1 - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b2 - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b3 - assert(read_value == 1); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b4 - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b5 - assert(read_value == 1); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b6 - assert(read_value == 1); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b7 - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b8 - assert(read_value == 1); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b9 - assert(read_value == 1); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b10 - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b11 - assert(read_value == 1); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b12 - assert(read_value == 1); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b13 - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b14 - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1);// b15 - assert(read_value == 1); - // 0x11 0x99 - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 2); - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 2); - assert(read_value == 1); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 2); - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1); - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 2); - assert(read_value == 3); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 2); - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1); - assert(read_value == 1); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 2); - assert(read_value == 2); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 2); - assert(read_value == 1); - // 0xA7 0xF4 0x86 0xCD 0x7D; - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x29F); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x348); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x1B3); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x17D); - // 0x58 0xAA 0xDB 0xAA 0xBD 0x34 - // 0xE0 0x3F 0x84 0xBA 0x91 0xEC - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1); - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x2C5); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x15B); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x1D5); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x17A); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 1); - assert(read_value == 0); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x34E); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x00F); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x384); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x2EA); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 10); - assert(read_value == 0x11E); - bit_pos_read = 0; - byte_pos_read = g_buffer; - // 0x96 0xD9 0x11 0x99 0xA7 0xF4 0x86 0xCD 0x7D 0x58 0xAA 0xDB 0xAA 0xBD 0x34 - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 15); - assert(read_value == 0x4B6C); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 15); - assert(read_value == 0x4466); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 15); - assert(read_value == 0x34FE); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 15); - assert(read_value == 0x486C); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 15); - assert(read_value == 0x6BEA); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 15); - assert(read_value == 0x62AB); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 15); - assert(read_value == 0x3755); - read_value = rlc_am_read_bit_field(&byte_pos_read, &bit_pos_read, 15); - assert(read_value == 0x3D34); -} -//----------------------------------------------------------------------------- -void rlc_am_v9_3_0_test_reset_sdus() -//----------------------------------------------------------------------------- -{ - int i, j; - - for (j = 0; j < 2; j++) { - for (i = 0; i < TEST_MAX_SEND_SDU; i++) { - g_send_sdu_ids[i][j]= -1; - } - - g_send_id_write_index[j] = 0; - g_send_id_read_index[j] = 0; - } -} -//----------------------------------------------------------------------------- -void rlc_am_v9_3_0_test_send_sdu(rlc_am_entity_t *am_txP, int sdu_indexP) -//----------------------------------------------------------------------------- -{ - mem_block_t *sdu; - sdu = get_free_mem_block (strlen(g_sdus[sdu_indexP]) + 1 + sizeof (struct rlc_am_data_req_alloc), __func__); - - if (sdu != NULL) { - // PROCESS OF COMPRESSION HERE: - printf("[FRAME %05d][RLC][MOD %02d][RB %02d] TX SDU %d %04d bytes\n",g_frame,am_txP->module_id, am_txP->rb_id, sdu_indexP, strlen(g_sdus[sdu_indexP]) + 1); - memset (sdu->data, 0, sizeof (struct rlc_am_data_req_alloc)); - strcpy (&sdu->data[sizeof (struct rlc_am_data_req_alloc)],g_sdus[sdu_indexP]); - ((struct rlc_am_data_req *) (sdu->data))->data_size = strlen(g_sdus[sdu_indexP])+ 1; - ((struct rlc_am_data_req *) (sdu->data))->conf = 1; - ((struct rlc_am_data_req *) (sdu->data))->mui = g_mui++; - ((struct rlc_am_data_req *) (sdu->data))->data_offset = sizeof (struct rlc_am_data_req_alloc); - rlc_am_data_req(am_txP, g_frame, sdu); - g_send_sdu_ids[g_send_id_write_index[am_txP->rb_id]++][am_txP->rb_id] = sdu_indexP; - assert(g_send_id_write_index[am_txP->rb_id] < TEST_MAX_SEND_SDU); - } else { - printf("Out of memory error\n"); - // exit(-1); - } -} -//----------------------------------------------------------------------------- -void rlc_am_v9_3_0_test_mac_rlc_loop (struct mac_data_ind *data_indP, struct mac_data_req *data_requestP, int *drop_countP, int *tx_packetsP, - int *dropped_tx_packetsP) { //----------------------------------------------------------------------------- - mem_block_t *tb_src; - mem_block_t *tb_dst; - unsigned int tb_size; - data_indP->no_tb = 0; - - while (data_requestP->data.nb_elements > 0) { - tb_src = list_remove_head (&data_requestP->data); - - if (tb_src != NULL) { - tb_size = ((struct mac_tb_req *) (tb_src->data))->tb_size_in_bits >> 3; - printf("[RLC-LOOP] FOUND TB SIZE IN BITS %d IN BYTES %u sizeof (mac_rlc_max_rx_header_size_t) %d\n", - ((struct mac_tb_req *) (tb_src->data))->tb_size_in_bits, - tb_size, sizeof (mac_rlc_max_rx_header_size_t)); - *tx_packetsP = *tx_packetsP + 1; - - if (*drop_countP == 0) { - tb_dst = get_free_mem_block(sizeof (mac_rlc_max_rx_header_size_t) + tb_size, __func__); - - if (tb_dst != NULL) { - ((struct mac_tb_ind *) (tb_dst->data))->first_bit = 0; - ((struct mac_tb_ind *) (tb_dst->data))->data_ptr = &tb_dst->data[sizeof (mac_rlc_max_rx_header_size_t)]; - ((struct mac_tb_ind *) (tb_dst->data))->size = tb_size; - ((struct mac_tb_ind *) (tb_dst->data))->error_indication = 0; - memcpy(((struct mac_tb_ind *) (tb_dst->data))->data_ptr, - &((struct mac_tb_req *) (tb_src->data))->data_ptr[0], - tb_size); - list_add_tail_eurecom(tb_dst, &data_indP->data); - data_indP->no_tb += 1; - } else { - printf("Out of memory error\n"); - // exit(-1); - } - } else { - printf("[RLC-LOOP] DROPPING 1 TB\n"); - *drop_countP = *drop_countP - 1; - *dropped_tx_packetsP = *dropped_tx_packetsP + 1; - } - - free_mem_block(tb_src, __func__); - - if (data_indP->no_tb > 0) { - printf("[RLC-LOOP] Exchange %d TBs\n",data_indP->no_tb); - } - } - } -} -//----------------------------------------------------------------------------- -void rlc_am_v9_3_0_test_exchange_pdus(rlc_am_entity_t *am_txP, - rlc_am_entity_t *am_rxP, - uint16_t bytes_txP, - uint16_t bytes_rxP) -//----------------------------------------------------------------------------- -{ - struct mac_data_req data_request_tx; - struct mac_data_req data_request_rx; - struct mac_data_ind data_ind_tx; - struct mac_data_ind data_ind_rx; - struct mac_status_ind tx_status; - struct mac_status_resp mac_rlc_status_resp_tx; - struct mac_status_resp mac_rlc_status_resp_rx; - memset(&data_request_tx, 0, sizeof(struct mac_data_req)); - memset(&data_request_rx, 0, sizeof(struct mac_data_req)); - memset(&data_ind_tx, 0, sizeof(struct mac_data_ind)); - memset(&data_ind_rx, 0, sizeof(struct mac_data_ind)); - memset(&tx_status, 0, sizeof(struct mac_status_ind)); - memset(&mac_rlc_status_resp_tx, 0, sizeof(struct mac_status_resp)); - memset(&mac_rlc_status_resp_rx, 0, sizeof(struct mac_status_resp)); - mac_rlc_status_resp_tx = rlc_am_mac_status_indication(am_txP, g_frame, bytes_txP, tx_status); - data_request_tx = rlc_am_mac_data_request(am_txP, g_frame); - mac_rlc_status_resp_rx = rlc_am_mac_status_indication(am_rxP, g_frame, bytes_rxP, tx_status); - data_request_rx = rlc_am_mac_data_request(am_rxP, g_frame); - rlc_am_v9_3_0_test_mac_rlc_loop(&data_ind_rx, &data_request_tx, &g_drop_tx, &g_tx_packets, &g_dropped_tx_packets); - rlc_am_v9_3_0_test_mac_rlc_loop(&data_ind_tx, &data_request_rx, &g_drop_rx, &g_rx_packets, &g_dropped_rx_packets); - rlc_am_mac_data_indication(am_rxP, g_frame, am_txP->is_enb, data_ind_rx); - rlc_am_mac_data_indication(am_txP, g_frame, am_txP->is_enb, data_ind_tx); - g_frame += 1; - //rlc_am_tx_buffer_display(am_txP,NULL); - //assert(am_txP->t_status_prohibit.time_out != 1); - //assert(am_rxP->t_status_prohibit.time_out != 1); - //assert(!((am_txP->vt_a == 954) && (am_txP->vt_s == 53))); - //assert(g_frame <= 151); - //check_mem_area(NULL); - //display_mem_load(); -} -//----------------------------------------------------------------------------- -void rlc_am_v9_3_0_test_data_conf(module_id_t module_idP, rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP) -//----------------------------------------------------------------------------- -{ - if (statusP == RLC_SDU_CONFIRM_YES) { - printf("[FRAME %05d][RLC][MOD %02d][RB %02d] CONFIRM SEND SDU MUI %05d\n",g_frame,module_idP, rb_idP, muiP); - } else { - printf("[FRAME %05d][RLC][MOD %02d][RB %02d] CONFIRM LOST SDU MUI %05d\n",g_frame,module_idP, rb_idP, muiP); - } -} -//----------------------------------------------------------------------------- -void rlc_am_v9_3_0_test_data_ind (module_id_t module_idP, rb_id_t rb_idP, sdu_size_t sizeP, mem_block_t *sduP) -//----------------------------------------------------------------------------- -{ - int i; - - for (i = 0; i < 37; i++) { - if (strcmp(g_sdus[i], sduP->data) == 0) { - printf("[FRAME %05d][RLC][MOD %02d][RB %02d] RX SDU %d %04d bytes\n",g_frame,module_idP, rb_idP, i, sizeP); - assert(TEST_MAX_SEND_SDU > g_send_id_read_index[rb_idP]); - assert(g_send_id_write_index[rb_idP^1] > g_send_id_read_index[rb_idP]); - - if (g_send_sdu_ids[g_send_id_read_index[rb_idP]][rb_idP^1] != i) { - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP]-2, - g_send_sdu_ids[g_send_id_read_index[rb_idP]-2][rb_idP^1]); - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP]-1, - g_send_sdu_ids[g_send_id_read_index[rb_idP]-1][rb_idP^1]); - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP], - g_send_sdu_ids[g_send_id_read_index[rb_idP]][rb_idP^1]); - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_id_read_index = %d sdu sent = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP], i); - } - - assert(g_send_sdu_ids[g_send_id_read_index[rb_idP]][rb_idP^1] == i); - g_send_id_read_index[rb_idP] += 1; - free_mem_block(sduP, __func__); - return; - } - } - - printf("[FRAME %05d][RLC][MOD %d][RB %d] RX UNKNOWN SDU %04d bytes\n",g_frame,module_idP, rb_idP, sizeP); - free_mem_block(sduP, __func__); - assert(1==2); -} -//----------------------------------------------------------------------------- -void rlc_am_v9_3_0_test_tx_rx() -//----------------------------------------------------------------------------- -{ - uint16_t max_retx_threshold = 255; - uint16_t poll_pdu = 8; - uint16_t poll_byte = 1000; - uint32_t t_poll_retransmit = 15; - uint32_t t_reordering = 5000; - uint32_t t_status_prohibit = 10; - int i,j,r; - srand (0); - rlc_am_init(&g_am_tx, g_frame); - rlc_am_init(&g_am_rx, g_frame); - rlc_am_set_debug_infos(&g_am_tx, g_frame, 0, 0, 0, 1, 1 /* LC-id = DRB-id */); - rlc_am_set_debug_infos(&g_am_rx, g_frame, 1, 1, 1, 1, 1 /* LC-id = DRB-id */); - rlc_am_configure(&g_am_tx, g_frame, max_retx_threshold, poll_pdu, poll_byte, t_poll_retransmit, t_reordering, t_status_prohibit); - rlc_am_configure(&g_am_rx, g_frame, max_retx_threshold, poll_pdu, poll_byte, t_poll_retransmit, t_reordering, t_status_prohibit); -#ifdef TEST1 - srand (0); - rlc_am_v9_3_0_test_reset_sdus(); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 1); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 8000, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 8000, 200); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 2); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 8000, 200); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 1); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 2); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 8000, 200); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 1); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 2); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 3); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 4); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 5); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 6); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 1000, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 1000, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 1000, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 1000, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 1000, 200); - rlc_am_rx_list_display(&g_am_tx, "RLC-AM TX:"); - rlc_am_rx_list_display(&g_am_rx, "RLC-AM RX:"); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_am_v9_3_0_test 1: END OF SIMPLE TEST SEVERAL SDUs IN PDU\n\n\n\n"); - rlc_am_v9_3_0_test_reset_sdus(); - - // RANDOM TESTS - for (i = g_send_id_write_index[0]; g_send_id_write_index[0] < TEST_MAX_SEND_SDU-12; i++) { - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 1); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 8000, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 8000, 200); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 2); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 8000, 200); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 1); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 2); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 8000, 200); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 1); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 2); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 3); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 4); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 5); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 6); - - for (i = 0; i < 50; i++) { - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 200, 200); - } - - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - } - - rlc_am_rx_list_display(&g_am_tx, "RLC-AM TX:"); - rlc_am_rx_list_display(&g_am_rx, "RLC-AM RX:"); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_am_v9_3_0_test 1: END OF TEST SEVERAL SDUs IN PDU\n\n\n\n"); -#endif -#ifdef TEST2 - srand (0); - rlc_am_v9_3_0_test_reset_sdus(); - // BIG SDU SMALL PDUS NO ERRORS - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 1); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 3, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 3, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 3, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 4, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 5, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 6, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 7, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 8, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 9, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 10, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 11, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 12, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 13, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 16, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 17, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 18, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 19, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 20, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 21, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 22, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 23, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 24, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 25, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 26, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 27, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 28, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 29, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 2000, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 2000, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 2000, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 2000, 200); - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 1); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 30, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 31, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 32, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 33, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 34, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 35, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 36, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 37, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 38, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 39, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 40, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 41, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 42, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 43, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 44, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 45, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 46, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 47, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 48, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 49, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 50, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 51, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 52, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 53, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 54, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 55, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 56, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 57, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 58, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 59, 200); - - //rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 60, 200); if uncomment: error because too many segments of SDU - for (i = 0; i < 24; i++) { - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 2000, 200); - } - - rlc_am_rx_list_display(&g_am_tx, "RLC-AM TX:"); - rlc_am_rx_list_display(&g_am_rx, "RLC-AM RX:"); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_am_v9_3_0_test 2: END OF TEST BIG SDU SMALL PDUs\n\n\n\n"); -#endif -#ifdef TEST3 - srand (0); - rlc_am_v9_3_0_test_reset_sdus(); - // BIG SDU SMALL PDUS ERRORs () - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, 1); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 3, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 3, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 3, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 4, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 5, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 6, 200); - g_drop_tx = 1; - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 7, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 8, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 9, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 10, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 11, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 12, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 13, 200); - g_drop_tx = 2; - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 16, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 17, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 18, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 19, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 20, 200); - g_drop_tx = 4; - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 21, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 22, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 23, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 24, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 25, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 26, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - - for (i = 0; i < 30; i++) { - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 500, 200); - } - - // Purge - for (i = 0; i < 24; i++) { - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, i); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - } - - for (i = 0; i < 100; i++) { - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 200); - } - - rlc_am_rx_list_display(&g_am_tx, "RLC-AM TX:"); - rlc_am_rx_list_display(&g_am_rx, "RLC-AM RX:"); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_am_v9_3_0_test 3: END OF TEST BIG SDU SMALL PDUs WITH ERRORS ON PHY LAYER\n\n\n\n"); -#endif -#ifdef TEST4 - srand (0); - rlc_am_v9_3_0_test_reset_sdus(); - - for (i = 2 ; i < 37 ; i++) { - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, i); - } - - for (i = 2 ; i < 37 ; i++) { - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, i); - } - - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 30, 100); - g_drop_tx = 4; - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 100, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 100, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 100, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 300, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 20, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 20, 100); - g_drop_tx = 4; - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 20, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 15, 100); - t_poll_retransmit = 6; - rlc_am_configure(&g_am_tx, g_frame, max_retx_threshold, poll_pdu, poll_byte, t_poll_retransmit, t_reordering, t_status_prohibit); - - for (i = 0 ; i < 50 ; i++) { - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 100, 100); - } - - //exit(0); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 400, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 400, 100); - //exit(0); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 400, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - //exit(0); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 14, 100); - rlc_am_rx_list_display(&g_am_tx, "RLC-AM TX:"); - rlc_am_rx_list_display(&g_am_rx, "RLC-AM RX:"); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_am_v9_3_0_test 4: END OF TEST SEVERAL SDUS IN PDUs WITH ERRORS ON PHY LAYER\n\n\n\n"); - assert (g_send_id_write_index[0] < TEST_MAX_SEND_SDU); -#endif -#ifdef TEST5 - srand (0); - rlc_am_v9_3_0_test_reset_sdus(); - - // RANDOM TESTS - for (i = 0; g_send_id_write_index < TEST_MAX_SEND_SDU-1; i++) { - //for (i = 0; g_send_id_write_index < 434; i++) { - printf("AM.TX SDU %d\n", g_am_tx.nb_sdu); - - if (g_am_tx.nb_sdu < (RLC_AM_SDU_CONTROL_BUFFER_SIZE - 16)) { - g_random_sdu = rand() % 37; - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, g_random_sdu); - } - - //g_random_nb_frames = (rand() % 2) + 1; - g_random_nb_frames = 1; - - for (j = 0; j < g_random_nb_frames; j++) { - g_random_tx_pdu_size = rand() % RLC_SDU_MAX_SIZE; - g_random_rx_pdu_size = rand() % RLC_SDU_MAX_SIZE; - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - } - - rlc_am_rx_list_display(&g_am_tx, "RLC-AM TX:"); - rlc_am_rx_list_display(&g_am_rx, "RLC-AM RX:"); - printf("g_send_id_read_index %d g_send_id_write_index %d\n", g_send_id_read_index[1], g_send_id_write_index[0]); - - for (j = 0; j < 100; j++) { - g_random_tx_pdu_size = rand() % RLC_SDU_MAX_SIZE; - g_random_rx_pdu_size = rand() % RLC_SDU_MAX_SIZE; - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - - rlc_am_rx_list_display(&g_am_tx, "RLC-AM TX:"); - rlc_am_rx_list_display(&g_am_rx, "RLC-AM RX:"); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_am_v9_3_0_test 5: END OF TEST RANDOM TX ONLY WITH NO ERRORS ON PHY LAYER\n\n\n\n"); -#endif - - for (r = 0; r < 128; r++) { - srand (r); -#ifdef TEST6 - - for (g_target_tx_error_rate = 0; g_target_tx_error_rate < TARGET_MAX_TX_ERROR_RATE; g_target_tx_error_rate++) { - for (g_target_rx_error_rate = 0; g_target_rx_error_rate < TARGET_MAX_RX_ERROR_RATE; g_target_rx_error_rate++) { - g_tx_packets = 0; - g_dropped_tx_packets = 0; - g_rx_packets = 0; - g_dropped_rx_packets = 0; - rlc_am_v9_3_0_test_reset_sdus(); - - // RANDOM TESTS - for (i = g_send_id_write_index[0]; g_send_id_write_index[0] < TEST_MAX_SEND_SDU-1; i++) { - printf("AM.TX SDU %d\n", g_am_tx.nb_sdu); - - if (g_am_tx.nb_sdu < (RLC_AM_SDU_CONTROL_BUFFER_SIZE - 2)) { - g_random_sdu = rand() % 37; - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, g_random_sdu); - } - - g_random_nb_frames = (rand() % 10) + 1; - - //g_random_nb_frames = 1; - for (j = 0; j < g_random_nb_frames; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - - int dropped = (rand() % 3); - - if ((dropped == 0) && (g_tx_packets > 0)) { - if ((((g_dropped_tx_packets + 1)*100) / g_tx_packets) <= g_target_tx_error_rate) { - g_drop_tx = 1; - } - } - - dropped = (rand() % 3); - - if ((dropped == 0) && (g_rx_packets > 0)) { - if ((((g_dropped_rx_packets + 1)*100) / g_rx_packets) <= g_target_rx_error_rate) { - g_drop_rx = 1; - } - } - } - - for (j = 0; j < 400; j++) { - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, 500, 500); - } - - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_am_v9_3_0_test 6: END OF TEST RANDOM (SEED=%d BLER TX=%d BLER RX=%d) TX ONLY WITH ERRORS ON PHY LAYER:\n\n\n\n", - r, g_target_tx_error_rate, g_target_rx_error_rate); - rlc_am_rx_list_display(&g_am_tx, "RLC-AM TX:"); - rlc_am_rx_list_display(&g_am_rx, "RLC-AM RX:"); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("REAL BLER TX=%d (TARGET=%d) BLER RX=%d (TARGET=%d) \n",(g_dropped_tx_packets*100)/g_tx_packets, g_target_tx_error_rate, - (g_dropped_rx_packets*100)/g_rx_packets, g_target_rx_error_rate); - } - } - -#endif -#ifdef TEST7 - - for (g_target_tx_error_rate = 0; g_target_tx_error_rate < TARGET_MAX_TX_ERROR_RATE; g_target_tx_error_rate++) { - for (g_target_rx_error_rate = 0; g_target_rx_error_rate < TARGET_MAX_RX_ERROR_RATE; g_target_rx_error_rate++) { - g_tx_packets = 0; - g_dropped_tx_packets = 0; - g_rx_packets = 0; - g_dropped_rx_packets = 0; - rlc_am_v9_3_0_test_reset_sdus(); - - for (i = g_send_id_write_index[0]; g_send_id_write_index[0] < TEST_MAX_SEND_SDU-1; i++) { - if (g_am_tx.nb_sdu < (RLC_AM_SDU_CONTROL_BUFFER_SIZE - 2)) { - g_random_sdu = rand() % 37; - rlc_am_v9_3_0_test_send_sdu(&g_am_tx, g_random_sdu); - - if (g_am_rx.nb_sdu < (RLC_AM_SDU_CONTROL_BUFFER_SIZE - 2)) { - g_random_sdu = rand() % 37; - rlc_am_v9_3_0_test_send_sdu(&g_am_rx, g_random_sdu); - } else { - i = i-1; - } - } else { - if (g_am_rx.nb_sdu < (RLC_AM_SDU_CONTROL_BUFFER_SIZE - 2)) { - g_random_sdu = rand() % 37; - rlc_am_v9_3_0_test_send_sdu(&g_am_rx, g_random_sdu); - } else { - i = i-1; - } - } - - g_random_nb_frames = rand() % 4; - - for (j = 0; j < g_random_nb_frames; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - - int dropped = (rand() % 3); - - if ((dropped == 0) && (g_tx_packets > 0)) { - if ((((g_dropped_tx_packets + 1)*100) / g_tx_packets) <= g_target_tx_error_rate) { - g_drop_tx = 1; - } - } - - dropped = (rand() % 3); - - if ((dropped == 0) && (g_rx_packets > 0)) { - if ((((g_dropped_rx_packets + 1)*100) / g_rx_packets) <= g_target_rx_error_rate) { - g_drop_rx = 1; - } - } - } - - for (j = 0; j < 100; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_am_v9_3_0_test_exchange_pdus(&g_am_tx, &g_am_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_am_v9_3_0_test 7: END OF TEST RANDOM (SEED=%d BLER TX=%d BLER RX=%d ) TX RX WITH ERRORS ON PHY LAYER:\n\n\n\n", - r, g_target_tx_error_rate, g_target_rx_error_rate); - rlc_am_rx_list_display(&g_am_tx, "RLC-AM TX:"); - rlc_am_rx_list_display(&g_am_rx, "RLC-AM RX:"); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - assert (g_send_id_read_index[0] == g_send_id_write_index[1]); - printf("REAL BLER TX=%d (TARGET=%d) BLER RX=%d (TARGET=%d) \n",(g_dropped_tx_packets*100)/g_tx_packets, g_target_tx_error_rate, - (g_dropped_rx_packets*100)/g_rx_packets, g_target_rx_error_rate); - } - } - -#endif - } -} -//----------------------------------------------------------------------------- -void rlc_am_v9_3_0_test_print_trace (void) -//----------------------------------------------------------------------------- -{ - void *array[100]; - size_t size; - char **strings; - size_t i; - size = backtrace (array, 100); - strings = backtrace_symbols (array, size); - printf ("Obtained %lu stack frames.\n", (unsigned long)size); - - - for (i = 0; i < size; i++) { - printf ("%s\n", strings[i]); - } - - free (strings); -} - -//----------------------------------------------------------------------------- -void rlc_am_v9_3_0_test(void) -//----------------------------------------------------------------------------- -{ - // initscr(); - // cbreak(); - // keypad(stdscr, true); - // under test - pool_buffer_init(); - set_comp_log(RLC, LOG_ERR, LOG_MED, 1); - rlc_am_v9_3_0_test_tx_rx(); - // already tested - rlc_am_v9_3_0_test_windows(); - rlc_am_v9_3_0_test_read_write_bit_field(); - printf("rlc_am_v9_3_0_test: END OF TESTS\n"); - exit(0); -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.h deleted file mode 100644 index 6be3867b1075b74b9dbd3b43863f8404a0ce8318..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_test.h -* \brief This file defines the prototypes of RLC AM test functions. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \company Eurecom -* \email: lionel.gauthier@eurecom.fr -* \note -* \bug -* \warning -*/ -# ifndef __RLC_AM_TEST_H__ -# define __RLC_AM_TEST_H__ -rlc_am_entity_t g_am_tx; -rlc_am_entity_t g_am_rx; - -void rlc_am_v9_3_0_test_windows(); -void rlc_am_v9_3_0_test_read_write_bit_field(); -void rlc_am_v9_3_0_test_data_conf(module_id_t module_idP, rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP); -void rlc_am_v9_3_0_test_send_sdu(rlc_am_entity_t *am_txP, int sdu_indexP); -void rlc_am_v9_3_0_test_exchange_pdus(rlc_am_entity_t *am_txP,rlc_am_entity_t *am_RxP, - uint16_t bytes_txP,uint16_t bytes_rxP); -void rlc_am_v9_3_0_test_mac_rlc_loop (struct mac_data_ind *data_indP, struct mac_data_req *data_requestP, int* drop_countP, int *tx_packetsP, int* dropped_tx_packetsP); -void rlc_am_v9_3_0_test_data_ind (module_id_t module_idP, rb_id_t rb_idP, sdu_size_t sizeP, - mem_block_t *sduP); -void rlc_am_v9_3_0_test_tx_rx(); -void rlc_am_v9_3_0_test_print_trace (void); -void rlc_am_v9_3_0_test(); -# endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c deleted file mode 100644 index 7e3e120477e36249654e0717f8661058b9b8d4c5..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_TIMER_POLL_RETRANSMIT_C 1 -//----------------------------------------------------------------------------- -//#include "rtos_header.h" -#include "platform_types.h" -#include "common/platform_constants.h" -//----------------------------------------------------------------------------- -#include "rlc_am.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" -//----------------------------------------------------------------------------- -void -rlc_am_check_timer_poll_retransmit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP -) -{ - // 5.2.2.3 Expiry of t-PollRetransmit - // Upon expiry of t-PollRetransmit, the transmitting side of an AM RLC entity shall: - // - if both the transmission buffer and the retransmission buffer are empty (excluding transmitted RLC data PDU - // awaiting for acknowledgements); or - // - if no new RLC data PDU can be transmitted (e.g. due to window stalling): - // - consider the AMD PDU with SN = VT(S) – 1 for retransmission; or - // - consider any AMD PDU which has not been positively acknowledged for retransmission; - // - include a poll in a RLC data PDU as described in section 5.2.2.1. - - if (rlc_pP->t_poll_retransmit.running) { - if ( - // CASE 1: start time out - // +-----------+------------------+----------+ - // | |******************| | - // +-----------+------------------+----------+ - //FRAME # 0 FRAME MAX - ((rlc_pP->t_poll_retransmit.ms_start < rlc_pP->t_poll_retransmit.ms_time_out) && - ((PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_poll_retransmit.ms_time_out) || - (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_poll_retransmit.ms_start))) || - // CASE 2: time out start - // +-----------+------------------+----------+ - // |***********| |**********| - // +-----------+------------------+----------+ - //FRAME # 0 FRAME MAX VALUE - ((rlc_pP->t_poll_retransmit.ms_start > rlc_pP->t_poll_retransmit.ms_time_out) && - (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_poll_retransmit.ms_start) && - (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_poll_retransmit.ms_time_out)) - ) { - //if (rlc_pP->t_poll_retransmit.frame_time_out <= ctxt_pP->frame) { - rlc_pP->t_poll_retransmit.running = 0; - rlc_pP->t_poll_retransmit.timed_out = 1; - rlc_pP->stat_timer_poll_retransmit_timed_out += 1; - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T_POLL_RETRANSMIT] TIME-OUT\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - - /* Check for any retransmittable PDU if Buffer Occupancy empty or window stall */ - if (((rlc_pP->sdu_buffer_occupancy == 0) && (rlc_pP->retrans_num_bytes_to_retransmit == 0)) || - (rlc_pP->vt_s == rlc_pP->vt_ms)) { - // 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) { - 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 ack=%d is empty vtA=%d vtS=%d LcId=%d\n", - // sn, tx_data_pdu_buffer_p->flags.ack,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - if(tx_data_pdu_buffer_p->mem_block == NULL){ - LOG_E(RLC, "RLC AM Tpoll Retx expiry sn=%d ack=%d is empty vtA=%d vtS=%d LcId=%d\n", - sn, tx_data_pdu_buffer_p->flags.ack,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - sn = RLC_AM_PREV_SN(sn); - continue; - } - - 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; - tx_data_pdu_buffer_p->retx_payload_size = tx_data_pdu_buffer_p->payload_size; - 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 += tx_data_pdu_buffer_p->payload_size; - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T_POLL_RETRANSMIT] TIME-OUT PUT SN=%d in ReTx Buffer\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),tx_data_pdu_buffer_p->sn); - break; - } - else - { - sn = RLC_AM_PREV_SN(sn); - } - } - } - - - rlc_pP->force_poll = true; - //BugFix : new ms_time_out is computed when next poll is transmitter - } - } -} -//----------------------------------------------------------------------------- -int -rlc_am_is_timer_poll_retransmit_timed_out( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP -) -{ - return rlc_pP->t_poll_retransmit.timed_out; -} -//----------------------------------------------------------------------------- -void -rlc_am_stop_and_reset_timer_poll_retransmit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP -) -{ - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T_POLL_RETRANSMIT] STOPPED AND RESET\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - rlc_pP->t_poll_retransmit.running = 0; - rlc_pP->t_poll_retransmit.ms_time_out = 0; - rlc_pP->t_poll_retransmit.ms_start = 0; - rlc_pP->t_poll_retransmit.timed_out = 0; -} -//----------------------------------------------------------------------------- -void -rlc_am_start_timer_poll_retransmit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP -) -{ - /* Stop timer if it was previously running */ - rlc_am_stop_and_reset_timer_poll_retransmit(ctxt_pP,rlc_pP); - - if (rlc_pP->t_poll_retransmit.ms_duration > 0) { - rlc_pP->t_poll_retransmit.running = 1; - rlc_pP->t_poll_retransmit.ms_time_out = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) + rlc_pP->t_poll_retransmit.ms_duration; - rlc_pP->t_poll_retransmit.ms_start = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T_POLL_RETRANSMIT] STARTED (TIME-OUT = FRAME %05d)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->t_poll_retransmit.ms_time_out); - } else { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T_POLL_RETRANSMIT] NOT STARTED, CAUSE CONFIGURED 0 ms\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - } - -} -//----------------------------------------------------------------------------- -void -rlc_am_init_timer_poll_retransmit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP, - const uint32_t ms_durationP) -{ - rlc_pP->t_poll_retransmit.running = 0; - rlc_pP->t_poll_retransmit.ms_time_out = 0; - rlc_pP->t_poll_retransmit.ms_start = 0; - rlc_pP->t_poll_retransmit.ms_duration = ms_durationP; - rlc_pP->t_poll_retransmit.timed_out = 0; -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.h deleted file mode 100644 index 5f8fd5bedc4a6fc71f2e18849cc1496d4dcf5a1e..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_timer_poll_retransmit.h -* \brief This file defines the prototypes of the functions manipulating the t-PollRetransmit timer. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_timers_impl_ RLC AM Timers Reference Implementation -* @ingroup _rlc_am_internal_impl_ -* @{ -*/ - -#ifndef __RLC_AM_TIMER_POLL_RETRANSMIT_H__ -# define __RLC_AM_TIMER_POLL_RETRANSMIT_H__ - -/*! \fn void rlc_am_check_timer_poll_retransmit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP) -* \brief Check if timer Poll-retransmit has timed-out, if so it is stopped and has the status "timed-out". -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. - -*/ -void rlc_am_check_timer_poll_retransmit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP); - -/*! \fn int rlc_am_is_timer_poll_retransmit_timed_out(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP) -* \brief Boolean function, check if timer Poll-retransmit has timed-out. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \return 1 if timer Poll-retransmit has timed-out, else 0. -*/ -int rlc_am_is_timer_poll_retransmit_timed_out( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP); - -/*! \fn void rlc_am_stop_and_reset_timer_poll_retransmit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP) -* \brief Stop and reset the timer Poll-retransmit. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. - -*/ -void rlc_am_stop_and_reset_timer_poll_retransmit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP); - -/*! \fn void rlc_am_start_timer_poll_retransmit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP) -* \brief Re-arm (based on RLC AM config parameter) and start timer Poll-retransmit. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] frame Frame index -*/ -void rlc_am_start_timer_poll_retransmit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP); - -/*! \fn void rlc_am_init_timer_poll_retransmit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP, const uint32_t time_outP) -* \brief Initialize the timer Poll-retransmit with RLC AM time-out config parameter. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] time_outP Time-out in frame units. -*/ -void rlc_am_init_timer_poll_retransmit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP, - const uint32_t time_outP); -/** @} */ -#endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c deleted file mode 100644 index e46f9c5377c0bc0319f82a4b1af46c22605506f0..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_TIMER_POLL_REORDERING_C 1 -//----------------------------------------------------------------------------- -#include "platform_types.h" -#include "common/platform_constants.h" -//----------------------------------------------------------------------------- -#include "rlc_am.h" -# include "LAYER2/MAC/mac_extern.h" -#include "common/utils//LOG/log.h" -//----------------------------------------------------------------------------- -void -rlc_am_check_timer_reordering( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP) -{ - - if (rlc_pP->t_reordering.running) { - if ( - // CASE 1: start time out - // +-----------+------------------+----------+ - // | |******************| | - // +-----------+------------------+----------+ - //FRAME # 0 FRAME MAX - ((rlc_pP->t_reordering.ms_start < rlc_pP->t_reordering.ms_time_out) && - ((PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_reordering.ms_time_out) || - (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_reordering.ms_start))) || - // CASE 2: time out start - // +-----------+------------------+----------+ - // |***********| |**********| - // +-----------+------------------+----------+ - //FRAME # 0 FRAME MAX VALUE - ((rlc_pP->t_reordering.ms_start > rlc_pP->t_reordering.ms_time_out) && - (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_reordering.ms_start) && - (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_reordering.ms_time_out)) - ) { - //if (rlc_pP->t_reordering.frame_time_out == ctxt_pP->frame) { - // 5.1.3.2.4 Actions when t-Reordering expires - // When t-Reordering expires, the receiving side of an AM RLC entity shall: - // - update VR(MS) to the SN of the first AMD PDU with SN >= VR(X) for which not all byte segments have been - // received; - // - if VR(H) > VR(MS): - // - start t-Reordering; - // - set VR(X) to VR(H). - - //AssertFatal (rlc_pP->vr_x != RLC_SN_UNDEFINED, "RLC AM TReordering Expiry vrX not defined LcId=%d\n", rlc_pP->channel_id); - if(rlc_pP->vr_x == RLC_SN_UNDEFINED){ - LOG_E(RLC, "RLC AM TReordering Expiry vrX not defined LcId=%d\n", rlc_pP->channel_id); - return; - } - - - rlc_pP->t_reordering.running = 0; - rlc_pP->t_reordering.timed_out = 1; - rlc_pP->stat_timer_reordering_timed_out += 1; - - rlc_am_pdu_info_t* pdu_info; - mem_block_t* cursor; - cursor = rlc_pP->receiver_buffer.head; - rlc_usn_t vr_ms_new = rlc_pP->vr_x; - - //AssertFatal (cursor != NULL, "RLC AM TReordering Expiry Rx PDU list empty LcId=%d\n", rlc_pP->channel_id); - if(cursor == NULL){ - LOG_E(RLC, "RLC AM TReordering Expiry Rx PDU list empty LcId=%d\n", rlc_pP->channel_id); - return; - } - - /* go to memblock up to vrX*/ - pdu_info = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - while ((cursor != NULL) && (RLC_AM_DIFF_SN(pdu_info->sn,rlc_pP->vr_r) < RLC_AM_DIFF_SN(vr_ms_new,rlc_pP->vr_r))) { - cursor = cursor->next; - if (cursor != NULL) { - pdu_info = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - } - } - - /* Now find a SN for which either no PDU is received or partially received */ - while ((cursor != NULL) && (vr_ms_new != rlc_pP->vr_h) && (pdu_info->sn == vr_ms_new) && (((rlc_am_rx_pdu_management_t*)(cursor->data))->all_segments_received > 0)) { - /* Increment vrMS if the PDU is fully received or if this is the last PDU segment */ - if ((pdu_info->rf == 0) || (pdu_info->lsf == 1)) { - vr_ms_new = RLC_AM_NEXT_SN(vr_ms_new); - } - cursor = cursor->next; - if (cursor != NULL) { - pdu_info = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - } - } - - /* Update vr_ms */ - rlc_pP->vr_ms = vr_ms_new; - - - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-REORDERING] TIME-OUT UPDATED VR(MS) %04d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->vr_ms); - - /* if new vrMS is lower than vrH, update vrX and restart timerReordering */ - if (rlc_pP->vr_ms != rlc_pP->vr_h) { - rlc_pP->vr_x = rlc_pP->vr_h; - rlc_pP->t_reordering.ms_time_out = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) + rlc_pP->t_reordering.ms_duration; - - - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-REORDERING] TIME-OUT, RESTARTED T-REORDERING, UPDATED VR(X) to VR(R) %04d\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->vr_x); - } - - /* Trigger a STATUS report */ - RLC_AM_SET_STATUS(rlc_pP->status_requested,RLC_AM_STATUS_TRIGGERED_T_REORDERING); - // Clear Delay flag if it was setup as it is useless due to Status PDU to be sent for TReordering expiry - RLC_AM_CLEAR_STATUS(rlc_pP->status_requested,RLC_AM_STATUS_TRIGGERED_DELAYED); - rlc_pP->sn_status_triggered_delayed = RLC_SN_UNDEFINED; - - } - } -} -//----------------------------------------------------------------------------- -void -rlc_am_stop_and_reset_timer_reordering( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP) -{ - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-REORDERING] STOPPED AND RESET\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - rlc_pP->t_reordering.running = 0; - rlc_pP->t_reordering.ms_time_out = 0; - rlc_pP->t_reordering.ms_start = 0; - rlc_pP->t_reordering.timed_out = 0; -} -//----------------------------------------------------------------------------- -void -rlc_am_start_timer_reordering( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP) -{ - rlc_pP->t_reordering.timed_out = 0; - - if (rlc_pP->t_reordering.running == 0){ - if (rlc_pP->t_reordering.ms_duration > 0) { - rlc_pP->t_reordering.running = 1; - rlc_pP->t_reordering.ms_time_out = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) + rlc_pP->t_reordering.ms_duration; - rlc_pP->t_reordering.ms_start = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-REORDERING] STARTED (TIME-OUT = %5u ms)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->t_reordering.ms_time_out); - } else { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-REORDERING] NOT STARTED, CAUSE CONFIGURED 0 ms\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - } - } -} -//----------------------------------------------------------------------------- -void -rlc_am_init_timer_reordering( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP, - const uint32_t ms_durationP) -{ - rlc_pP->t_reordering.running = 0; - rlc_pP->t_reordering.ms_time_out = 0; - rlc_pP->t_reordering.ms_start = 0; - rlc_pP->t_reordering.ms_duration = ms_durationP; - rlc_pP->t_reordering.timed_out = 0; -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.h deleted file mode 100644 index bca3e8376398c9e1605deae5f1363c4d4300f7b4..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_timer_reordering.h -* \brief This file defines the prototypes of the functions manipulating the t-Reordering timer. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_timers_impl_ RLC AM Timers Reference Implementation -* @ingroup _rlc_am_internal_impl_ -* @{ -*/ -#ifndef __RLC_AM_TIMER_REORDERING_H__ -# define __RLC_AM_TIMER_REORDERING_H__ - -/*! \fn void rlc_am_check_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP) -* \brief Check if timer reordering has timed-out, if so it is stopped and has the status "timed-out". -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void rlc_am_check_timer_reordering( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP); - -/*! \fn void rlc_am_stop_and_reset_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP) -* \brief Stop and reset the timer reordering. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void rlc_am_stop_and_reset_timer_reordering( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP); - -/*! \fn void rlc_am_start_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP) -* \brief Re-arm (based on RLC AM config parameter) and start timer reordering. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void rlc_am_start_timer_reordering( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP); - -/*! \fn void rlc_am_init_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP, const uint32_t time_outP) -* \brief Initialize the timer reordering with RLC AM time-out config parameter. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] time_outP Time-out in frameP units. -*/ -void rlc_am_init_timer_reordering( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t* const rlc_pP, - const uint32_t time_outP); -/** @} */ -#endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c deleted file mode 100644 index 7359b6a07f85506b6dc1a23421e6b1379b892c2a..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_TIMER_STATUS_PROHIBIT_C 1 -//----------------------------------------------------------------------------- -#include "platform_types.h" -#include "common/platform_constants.h" -//----------------------------------------------------------------------------- -#include "rlc_am.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" -//----------------------------------------------------------------------------- -void -rlc_am_check_timer_status_prohibit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t * const rlc_pP) -{ - if (rlc_pP->t_status_prohibit.ms_duration > 0) { - if (rlc_pP->t_status_prohibit.running) { - if ( - // CASE 1: start time out - // +-----------+------------------+----------+ - // | |******************| | - // +-----------+------------------+----------+ - //FRAME # 0 FRAME MAX - ((rlc_pP->t_status_prohibit.ms_start < rlc_pP->t_status_prohibit.ms_time_out) && - ((PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_status_prohibit.ms_time_out) || - (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_status_prohibit.ms_start))) || - // CASE 2: time out start - // +-----------+------------------+----------+ - // |***********| |**********| - // +-----------+------------------+----------+ - //FRAME # 0 FRAME MAX VALUE - ((rlc_pP->t_status_prohibit.ms_start > rlc_pP->t_status_prohibit.ms_time_out) && - (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_status_prohibit.ms_start) && - (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_status_prohibit.ms_time_out)) - ) { - - //if ((rlc_pP->t_status_prohibit.frame_time_out <= ctxt_pP->frame) && (rlc_pP->t_status_prohibit.frame_start)) { - rlc_pP->t_status_prohibit.running = 0; - rlc_pP->t_status_prohibit.timed_out = 1; - rlc_pP->stat_timer_status_prohibit_timed_out += 1; - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-STATUS-PROHIBIT] TIME-OUT\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - //#warning TO DO rlc_am_check_timer_status_prohibit - rlc_am_stop_and_reset_timer_status_prohibit(ctxt_pP, rlc_pP); - /* Clear StatusProhibit flag */ - RLC_AM_CLEAR_STATUS(rlc_pP->status_requested,RLC_AM_STATUS_PROHIBIT); - //rlc_pP->t_status_prohibit.frame_time_out = ctxt_pP->frame + rlc_pP->t_status_prohibit.time_out; - } - } - } -} -//----------------------------------------------------------------------------- -void -rlc_am_stop_and_reset_timer_status_prohibit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP -) -{ - if (rlc_pP->t_status_prohibit.ms_duration > 0) { - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-STATUS-PROHIBIT] STOPPED AND RESET\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - rlc_pP->t_status_prohibit.running = 0; - rlc_pP->t_status_prohibit.ms_time_out = 0; - rlc_pP->t_status_prohibit.ms_start = 0; - rlc_pP->t_status_prohibit.timed_out = 0; - } -} -//----------------------------------------------------------------------------- -void -rlc_am_start_timer_status_prohibit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP -) -{ - rlc_pP->t_status_prohibit.timed_out = 0; - - if (rlc_pP->t_status_prohibit.running == 0){ - if (rlc_pP->t_status_prohibit.ms_duration > 0) { - rlc_pP->t_status_prohibit.running = 1; - rlc_pP->t_status_prohibit.ms_time_out = rlc_pP->t_status_prohibit.ms_duration + PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); - rlc_pP->t_status_prohibit.ms_start = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); - RLC_AM_SET_STATUS(rlc_pP->status_requested,RLC_AM_STATUS_PROHIBIT); - LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-STATUS-PROHIBIT] STARTED (TIME-OUT = %u ms)\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->t_status_prohibit.ms_time_out); - LOG_D(RLC, "TIME-OUT = FRAME %u\n", rlc_pP->t_status_prohibit.ms_time_out); - } else { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[T-STATUS-PROHIBIT] NOT STARTED, CAUSE CONFIGURED 0 ms\n", - PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - } - } -} -//----------------------------------------------------------------------------- -void rlc_am_init_timer_status_prohibit( - const protocol_ctxt_t* const ctxt_pP, - rlc_am_entity_t *const rlc_pP, - const uint32_t ms_durationP) -{ - rlc_pP->t_status_prohibit.running = 0; - rlc_pP->t_status_prohibit.ms_time_out = 0; - rlc_pP->t_status_prohibit.ms_start = 0; - rlc_pP->t_status_prohibit.ms_duration = ms_durationP; - rlc_pP->t_status_prohibit.timed_out = 0; -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.h deleted file mode 100644 index 04807418593d0cce4ea833e478ccf104fc596460..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_timer_status_prohibit.h -* \brief This file defines the prototypes of the functions manipulating the t-StatusProhibit timer. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_timers_impl_ RLC AM Timers Reference Implementation -* @ingroup _rlc_am_internal_impl_ -* @{ -*/ -#ifndef __RLC_AM_TIMER_STATUS_PROHIBIT_H__ -# define __RLC_AM_TIMER_STATUS_PROHIBIT_H__ - - -/*! \fn void rlc_am_check_timer_status_prohibit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP) -* \brief Check if timer status-prohibit has timed-out, if so it is stopped and has the status "timed-out". -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void rlc_am_check_timer_status_prohibit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP); - -/*! \fn void rlc_am_stop_and_reset_timer_status_prohibit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP) -* \brief Stop and reset the timer status-prohibit. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void rlc_am_stop_and_reset_timer_status_prohibit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP); - -/*! \fn void rlc_am_start_timer_status_prohibit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP) -* \brief Re-arm (based on RLC AM config parameter) and start timer status-prohibit. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -*/ -void rlc_am_start_timer_status_prohibit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP); - -/*! \fn void rlc_am_init_timer_status_prohibit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP, const uint32_t time_outP) -* \brief Initialize the timer status-prohibit with RLC AM time-out config parameter. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] time_outP Time-out in frameP units. -*/ -void rlc_am_init_timer_status_prohibit(const protocol_ctxt_t* const ctxt_pP, rlc_am_entity_t* const rlc_pP, const uint32_t time_outP); -/** @} */ -#endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.c deleted file mode 100644 index 24f0b12214fb0536ff5e19a2e1198151894f079f..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_AM_MODULE 1 -#define RLC_AM_WINDOWS_C 1 -//----------------------------------------------------------------------------- -#include <assert.h> -//----------------------------------------------------------------------------- -#include "platform_types.h" -//----------------------------------------------------------------------------- -#include "rlc_am.h" -#include "common/utils/LOG/log.h" -//----------------------------------------------------------------------------- -signed int rlc_am_in_tx_window( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t snP) -{ - rlc_usn_t shifted_sn; - rlc_usn_t upper_bound; - - if (snP >= RLC_AM_SN_MODULO) { - return 0; - } - - shifted_sn = ((rlc_usn_t)(snP - rlc_pP->vt_a)) % RLC_AM_SN_MODULO; - upper_bound = ((rlc_usn_t)(rlc_pP->vt_ms - rlc_pP->vt_a)) % RLC_AM_SN_MODULO; - - if ((shifted_sn >= 0) && (shifted_sn < upper_bound)) { - return 1; - } else { - return 0; - } -} -//----------------------------------------------------------------------------- -signed int -rlc_am_in_rx_window( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t snP) -{ - rlc_usn_t shifted_sn; - rlc_usn_t upper_bound; - - if (snP >= RLC_AM_SN_MODULO) { - return 0; - } - - shifted_sn = ((rlc_usn_t)(snP - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; - upper_bound = ((rlc_usn_t)(rlc_pP->vr_mr - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; - - if ((shifted_sn >= 0) && (shifted_sn < upper_bound)) { - return 1; - } else { - return 0; - } -} -//----------------------------------------------------------------------------- -signed int -rlc_am_sn_gte_vr_h( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t snP) -{ - rlc_usn_t shifted_sn; - rlc_usn_t upper_bound; - - if (snP >= RLC_AM_SN_MODULO) { - return 0; - } - - shifted_sn = ((rlc_usn_t)(snP - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; - upper_bound = ((rlc_usn_t)(rlc_pP->vr_h - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; - - if (shifted_sn >= upper_bound) { - return 1; - } else { - return 0; - } -} -//----------------------------------------------------------------------------- -signed int rlc_am_sn_gte_vr_x( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t snP) -{ - rlc_usn_t shifted_sn; - rlc_usn_t upper_bound; - - if (snP >= RLC_AM_SN_MODULO) { - return 0; - } - - shifted_sn = ((rlc_usn_t)(snP - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; - upper_bound = ((rlc_usn_t)(rlc_pP->vr_x - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; - - if (shifted_sn >= upper_bound) { - return 1; - } else { - return 0; - } -} -//----------------------------------------------------------------------------- -signed int -rlc_am_sn_gt_vr_ms( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t snP) -{ - rlc_usn_t shifted_sn; - rlc_usn_t upper_bound; - - if (snP >= RLC_AM_SN_MODULO) { - return 0; - } - - shifted_sn = ((rlc_usn_t)(snP - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; - upper_bound = ((rlc_usn_t)(rlc_pP->vr_ms - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; - - if (shifted_sn > upper_bound) { - return 1; - } else { - return 0; - } -} -//----------------------------------------------------------------------------- -signed int -rlc_am_tx_sn1_gt_sn2( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t sn1P, - const rlc_sn_t sn2P) -{ - rlc_usn_t shifted_sn; - rlc_usn_t upper_bound; - - if ((sn1P >= RLC_AM_SN_MODULO) || (sn2P >= RLC_AM_SN_MODULO)) { - return 0; - } - - shifted_sn = ((rlc_usn_t)(sn1P - rlc_pP->vt_a)) % RLC_AM_SN_MODULO; - upper_bound = ((rlc_usn_t)(sn2P - rlc_pP->vt_a)) % RLC_AM_SN_MODULO; - - if (shifted_sn > upper_bound) { - return 1; - } else { - return 0; - } -} -//----------------------------------------------------------------------------- -signed int -rlc_am_rx_sn1_gt_sn2( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t sn1P, - const rlc_sn_t sn2P) -{ - rlc_usn_t shifted_sn; - rlc_usn_t upper_bound; - - if ((sn1P >= RLC_AM_SN_MODULO) || (sn2P >= RLC_AM_SN_MODULO)) { - return 0; - } - - shifted_sn = ((rlc_usn_t)(sn1P - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; - upper_bound = ((rlc_usn_t)(sn2P - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; - - if (shifted_sn > upper_bound) { - return 1; - } else { - return 0; - } -} diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.h deleted file mode 100644 index be49e94120a021913945785c5d495ba5bf18fdba..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_am_windows.h -* \brief This file defines the prototypes of the functions testing window, based on SN modulo and rx and tx protocol state variables. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_am_windowing_impl_ RLC AM Windowing Reference Implementation -* @ingroup _rlc_am_internal_impl_ -* @{ -*/ -# ifndef __RLC_AM_WINDOWS_H__ -# define __RLC_AM_WINDOWS_H__ -//----------------------------------------------------------------------------- - -/*! \fn signed int rlc_am_in_tx_window(const protocol_ctxt_t* const ctxt_pP,const rlc_am_entity_t* const rlc_pP, const rlc_sn_t snP) -* \brief Boolean function, check if sequence number is VT(A) <= snP < VT(MS). -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] snP Sequence number. -* \return 1 if snP in tx window, else 0. -*/ -signed int rlc_am_in_tx_window( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t snP); - -/*! \fn signed int rlc_am_in_rx_window(const protocol_ctxt_t* const ctxt_pP,const rlc_am_entity_t* const rlc_pP, const rlc_sn_t snP) -* \brief Boolean function, check if sequence number is VR(R) <= snP < VR(MR). -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] snP Sequence number. -* \return 1 if snP in rx window, else 0. -*/ -signed int rlc_am_in_rx_window( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t snP); - -/*! \fn signed int rlc_am_sn_gte_vr_h (const protocol_ctxt_t* const ctxt_pP,const rlc_am_entity_t* const rlc_pP, const rlc_sn_t snP) -* \brief Boolean function, check if sequence number is greater than or equal VR(R). -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] snP Sequence number. -* \return 1 if sequence number is greater than or equal VR(R), else 0. -*/ -signed int rlc_am_sn_gte_vr_h ( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t snP); - -/*! \fn signed int rlc_am_sn_gte_vr_x (const protocol_ctxt_t* const ctxt_pP,const rlc_am_entity_t* const rlc_pP, const rlc_sn_t snP) -* \brief Boolean function, check if sequence number is greater than or equal VR(X). -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] snP Sequence number. -* \return 1 if sequence number is greater than or equal VR(X), else 0. -*/ -signed int rlc_am_sn_gte_vr_x ( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t snP); - -/*! \fn signed int rlc_am_sn_gt_vr_ms (const protocol_ctxt_t* const ctxt_pP,const rlc_am_entity_t* const rlc_pP, const rlc_sn_t snP) -* \brief Boolean function, check if sequence number is greater than VR(MS). -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] snP Sequence number. -* \return 1 if sequence number is greater than VR(MS), else 0. -*/ -signed int rlc_am_sn_gt_vr_ms( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t snP); - -/*! \fn signed int rlc_am_tx_sn1_gt_sn2 (const protocol_ctxt_t* const ctxt_pP,const rlc_am_entity_t* const rlc_pP, const rlc_sn_t sn1P, const rlc_sn_t sn2P) -* \brief Boolean function, in the context of the tx window, check if sn1P is greater than sn2P. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] sn1P Sequence number. -* \param[in] sn2P Sequence number. -* \return 1 if sn1P is greater than sn2P, else 0. -*/ -signed int rlc_am_tx_sn1_gt_sn2( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t sn1P, - const rlc_sn_t sn2P); - -/*! \fn signed int rlc_am_rx_sn1_gt_sn2(const protocol_ctxt_t* const ctxt_pP,const rlc_am_entity_t* const rlc_pP, const rlc_sn_t sn1P, const rlc_sn_t sn2P) -* \brief Boolean function, in the context of the rx window, check if sn1P is greater than sn2P. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC AM protocol instance pointer. -* \param[in] sn1P Sequence number. -* \param[in] sn2P Sequence number. -* \return 1 if sn1P is greater than sn2P, else 0. -*/ -signed int rlc_am_rx_sn1_gt_sn2( - const protocol_ctxt_t* const ctxt_pP, - const rlc_am_entity_t* const rlc_pP, - const rlc_sn_t sn1P, - const rlc_sn_t sn2P); -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c deleted file mode 100644 index d699d1d6a4a33bb29774ec1954f197cbb74944a4..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_TM_MODULE 1 -#define RLC_TM_C 1 -//----------------------------------------------------------------------------- -#include "platform_types.h" -#include "common/platform_constants.h" -//----------------------------------------------------------------------------- -#include "rlc_tm.h" -#include "mac_primitives.h" -#include "rlc_primitives.h" -#include "list.h" -#include "LAYER2/MAC/mac_extern.h" -//----------------------------------------------------------------------------- -void rlc_tm_send_sdu(const protocol_ctxt_t* const ctxt_pP, - rlc_tm_entity_t * const rlc_pP, - const bool error_indicationP, - uint8_t * const srcP, - const sdu_size_t length_in_bitsP) -{ - int length_in_bytes; -#if DEBUG_RLC_TM_DISPLAY_ASCII_DATA - int index; -#endif -#if DEBUG_RLC_TM_REASSEMBLY - LOG_D(RLC, PROTOCOL_RLC_TM_CTXT_FMT"[SEND_SDU] %d bits\n", - PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_pP), - length_in_bitsP); -#endif - length_in_bytes = (length_in_bitsP + 7) >> 3; - - if (rlc_pP->output_sdu_in_construction == NULL) { - rlc_pP->output_sdu_in_construction = get_free_mem_block (length_in_bytes, __func__); - } - - if ((rlc_pP->output_sdu_in_construction)) { -#if DEBUG_RLC_TM_DISPLAY_ASCII_DATA - LOG_D(RLC, PROTOCOL_RLC_TM_CTXT_FMT"[SEND_SDU] DATA :", - PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_pP)); - - for (index = 0; index < length_in_bytes; index++) { - LOG_T (RLC,"%c", srcP[index]); - } - - LOG_T (RLC,"\n"); -#endif - - memcpy (&rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write], srcP, length_in_bytes); - - rlc_data_ind ( - ctxt_pP, - BOOL_NOT(rlc_pP->is_data_plane), - MBMS_FLAG_NO, - rlc_pP->rb_id, - length_in_bytes, - rlc_pP->output_sdu_in_construction); - rlc_pP->output_sdu_in_construction = NULL; - } else { - LOG_D (RLC,"[RLC_TM %p][SEND_SDU] ERROR OUTPUT SDU IS NULL\n", rlc_pP); - } -} -//----------------------------------------------------------------------------- -void -rlc_tm_no_segment ( - const protocol_ctxt_t* const ctxt_pP, - rlc_tm_entity_t *const rlc_pP -) -{ - mem_block_t *pdu_p = NULL; - struct rlc_tm_tx_sdu_management *sdu_mngt_p = NULL; - struct rlc_tm_tx_pdu_management *pdu_mngt_p = NULL; - int nb_pdu_to_transmit = 1; - - // only one SDU per TTI - while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index]) && (nb_pdu_to_transmit > 0)) { - - sdu_mngt_p = ((struct rlc_tm_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data)); - - if (!(pdu_p = get_free_mem_block (((rlc_pP->rlc_pdu_size + 7) >> 3) + sizeof (struct rlc_tm_tx_data_pdu_struct) + GUARD_CRC_LIH_SIZE, __func__))) { - LOG_D(RLC, PROTOCOL_RLC_TM_CTXT_FMT"[SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", - PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_pP)); - return; - } - - // SHOULD BE OPTIMIZED...SOON - pdu_mngt_p = (struct rlc_tm_tx_pdu_management *) (pdu_p->data); - memset (pdu_p->data, 0, sizeof (struct rlc_tm_tx_pdu_management)); - pdu_mngt_p->first_byte = (uint8_t*)&pdu_p->data[sizeof (struct rlc_tm_tx_data_pdu_struct)]; - - memcpy (pdu_mngt_p->first_byte, sdu_mngt_p->first_byte, ((rlc_pP->rlc_pdu_size + 7) >> 3)); - ((struct mac_tb_req *) (pdu_p->data))->rlc = NULL; - ((struct mac_tb_req *) (pdu_p->data))->data_ptr = pdu_mngt_p->first_byte; - ((struct mac_tb_req *) (pdu_p->data))->first_bit = 0; - ((struct mac_tb_req *) (pdu_p->data))->tb_size = rlc_pP->rlc_pdu_size >> 3; - list_add_tail_eurecom (pdu_p, &rlc_pP->pdus_to_mac_layer); - - rlc_pP->buffer_occupancy -= (sdu_mngt_p->sdu_size >> 3); - free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index], __func__); - rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL; - rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer; - rlc_pP->nb_sdu -= 1; - } -} -//----------------------------------------------------------------------------- -void -rlc_tm_rx ( - const protocol_ctxt_t* const ctxt_pP, - void * const argP, - struct mac_data_ind data_indP) -{ - - rlc_tm_entity_t * const rlc_p = (rlc_tm_entity_t *) argP; - mem_block_t *tb_p; - uint8_t *first_byte_p; - - rlc_p->output_sdu_size_to_write = 0; // size of sdu reassemblied - - while ((tb_p = list_remove_head (&data_indP.data))) { - first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr; - - ((struct rlc_tm_rx_pdu_management *) (tb_p->data))->first_byte = first_byte_p; - - rlc_tm_send_sdu (ctxt_pP, rlc_p, (((struct mac_tb_ind *) (tb_p->data))->error_indication), first_byte_p, data_indP.tb_size); - free_mem_block (tb_p, __func__); - } -} - -//----------------------------------------------------------------------------- -struct mac_status_resp -rlc_tm_mac_status_indication ( - const protocol_ctxt_t* const ctxt_pP, - void * const rlc_pP, - struct mac_status_ind tx_statusP) -{ - struct mac_status_resp status_resp; - - status_resp.buffer_occupancy_in_bytes = ((rlc_tm_entity_t *) rlc_pP)->buffer_occupancy; - status_resp.buffer_occupancy_in_pdus = status_resp.buffer_occupancy_in_bytes / ((rlc_tm_entity_t *) rlc_pP)->rlc_pdu_size; - status_resp.rlc_info.rlc_protocol_state = ((rlc_tm_entity_t *) rlc_pP)->protocol_state; - status_resp.head_sdu_creation_time = 0; - return status_resp; -} - -//----------------------------------------------------------------------------- -struct mac_data_req -rlc_tm_mac_data_request ( - const protocol_ctxt_t* const ctxt_pP, - void * const rlc_pP) -{ - rlc_tm_entity_t* rlc_p = (rlc_tm_entity_t*) rlc_pP; - struct mac_data_req data_req; - - rlc_tm_no_segment (ctxt_pP, rlc_p); - list_init (&data_req.data, NULL); - list_add_list (&rlc_p->pdus_to_mac_layer, &data_req.data); - data_req.buffer_occupancy_in_bytes = rlc_p->buffer_occupancy; - data_req.buffer_occupancy_in_pdus = data_req.buffer_occupancy_in_bytes / rlc_p->rlc_pdu_size; - data_req.rlc_info.rlc_protocol_state = rlc_p->protocol_state; - - if (data_req.data.nb_elements > 0) { - LOG_D(RLC, PROTOCOL_RLC_TM_CTXT_FMT" MAC_DATA_REQUEST %d TBs\n", - PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_p), - data_req.data.nb_elements); - } - data_req.ue_id_type_indicator = 0; - - return data_req; -} - -//----------------------------------------------------------------------------- -void -rlc_tm_mac_data_indication ( - const protocol_ctxt_t* const ctxt_pP, - void * const rlc_pP, - struct mac_data_ind data_indP) -{ - - if (data_indP.data.nb_elements > 0) { - LOG_D(RLC, PROTOCOL_RLC_TM_CTXT_FMT" MAC_DATA_IND %d TBs\n", - PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, ((rlc_tm_entity_t*) rlc_pP)), - data_indP.data.nb_elements); - } - - rlc_tm_rx (ctxt_pP, rlc_pP, data_indP); -} - -//----------------------------------------------------------------------------- -void -rlc_tm_data_req ( - const protocol_ctxt_t* const ctxt_pP, - void *const rlc_pP, - mem_block_t *const sdu_pP) -{ - rlc_tm_entity_t *rlc_p = (rlc_tm_entity_t *) rlc_pP; - -#if DEBUG_RLC_TM_DATA_REQUEST - LOG_D (RLC, PROTOCOL_RLC_TM_CTXT_FMT" RLC_TM_DATA_REQ size %d Bytes, BO %ld , NB SDU %d current_sdu_index=%d next_sdu_index=%d\n", - PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_p), - ((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); -#endif - - // not in 3GPP specification but the buffer may be full if not correctly configured - if (rlc_p->input_sdus[rlc_p->next_sdu_index] == NULL) { - ((struct rlc_tm_tx_sdu_management *) (sdu_pP->data))->sdu_size = ((struct rlc_tm_data_req *) (sdu_pP->data))->data_size; - rlc_p->buffer_occupancy += ((struct rlc_tm_tx_sdu_management *) (sdu_pP->data))->sdu_size >> 3; - rlc_p->nb_sdu += 1; - ((struct rlc_tm_tx_sdu_management *) (sdu_pP->data))->first_byte = (uint8_t*)&sdu_pP->data[sizeof (struct rlc_tm_data_req_alloc)]; - rlc_p->input_sdus[rlc_p->next_sdu_index] = sdu_pP; - rlc_p->next_sdu_index = (rlc_p->next_sdu_index + 1) % rlc_p->size_input_sdus_buffer; - } else { - free_mem_block (sdu_pP, __func__); - } -} diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.h b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.h deleted file mode 100644 index de7b9b8170673969f6713ba3b59983de27f03e90..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_tm.h -* \brief This file, and only this file must be included by code that interact with RLC TM layer. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_tm_impl_ RLC TM Layer Reference Implementation -* @ingroup _rlc_impl_ -* @{ -*/ -# ifndef __RLC_TM_H__ -# define __RLC_TM_H__ -# include "platform_types.h" -# include "rlc_def.h" -# include "rlc_def_lte.h" -# include "rlc_tm_structs.h" -# include "rlc_tm_entity.h" -# include "mem_block.h" -# include "rlc_tm_init.h" - -#define PROTOCOL_RLC_TM_CTXT_FMT PROTOCOL_CTXT_FMT"[%s %02ld]" -#define PROTOCOL_RLC_TM_CTXT_ARGS(CTXT_Pp, rLC_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\ - (rLC_Pp->is_data_plane) ? "DRB TM" : "SRB TM",\ - rLC_Pp->rb_id - - -/*! \fn void rlc_tm_send_sdu ( -* const protocol_ctxt_t* const ctxt_pP, -* rlc_tm_entity_t * const rlc_pP, -* const bool error_indicationP, -* uint8_t * const srcP, -* const sdu_size_t length_in_bitsP) -* \brief Send SDU if any reassemblied to upper layer. -* \param[in] rlcP RLC TM protocol instance pointer. -* \param[in] error_indicationP Error indicated by lower layers for this SDU. -* \param[in] srcP SDU data pointer. -* \param[in] length_in_bitsP Length of SDU in bits. -*/ -void rlc_tm_send_sdu(const protocol_ctxt_t* const ctxt_pP, - rlc_tm_entity_t * const rlc_pP, - const bool error_indicationP, - uint8_t * const srcP, - const sdu_size_t length_in_bitsP); - -/*! \fn void rlc_tm_no_segment (const protocol_ctxt_t* const ctxt_pP, rlc_tm_entity_t * const rlcP) -* \brief Schedule a SDU to be transmited by lower layers. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC TM protocol instance pointer. -*/ -void rlc_tm_no_segment ( - const protocol_ctxt_t* const ctxt_pP, - rlc_tm_entity_t *const rlcP); - -/*! \fn void rlc_tm_rx (const protocol_ctxt_t* const ctxt_pP,void *const rlcP, struct mac_data_ind data_indP) -* \brief Process the received PDUs from lower layer. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC TM protocol instance pointer. -* \param[in] data_indP PDUs from MAC. -*/ -void rlc_tm_rx ( - const protocol_ctxt_t* const ctxt_pP, - void *const rlcP, - struct mac_data_ind data_indP); - - -/*! \fn struct mac_status_resp rlc_tm_mac_status_indication (const protocol_ctxt_t* const ctxt_pP, void * const rlcP, struct mac_status_ind tx_statusP) -* \brief Request the maximum number of bytes that can be served by RLC instance to MAC and fix the amount of bytes requested by MAC for next RLC transmission. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC TM protocol instance pointer. -* \param[in] tx_statusP Transmission status given by MAC on previous MAC transmission of the PDU. -* \return The maximum number of bytes that can be served by RLC instance to MAC. -*/ -struct mac_status_resp -rlc_tm_mac_status_indication ( - const protocol_ctxt_t* const ctxt_pP, - void * const rlc_pP, - struct mac_status_ind tx_statusP); - - -/*! \fn struct mac_data_req rlc_tm_mac_data_request (const protocol_ctxt_t* const ctxt_pP, void * const rlcP) -* \brief Gives PDUs to lower layer MAC. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC TM protocol instance pointer. -* \return A PDU of the previously requested number of bytes, and the updated maximum number of bytes that can be served by RLC instance to MAC for next RLC transmission. -*/ -struct mac_data_req rlc_tm_mac_data_request ( - const protocol_ctxt_t* const ctxt_pP, - void * const rlcP); - - -/*! \fn void rlc_tm_mac_data_indication (const protocol_ctxt_t* const ctxt_pP,void * const rlcP, struct mac_data_ind data_indP) -* \brief Receive PDUs from lower layer MAC. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC TM protocol instance pointer. -* \param[in] data_indP PDUs from MAC. -*/ -void rlc_tm_mac_data_indication ( - const protocol_ctxt_t* const ctxt_pP, - void * const rlcP, - struct mac_data_ind data_indP); - - -/*! \fn void rlc_tm_data_req (const protocol_ctxt_t* const ctxt_pP,void * const rlcP, mem_block_t * const sduP) -* \brief Interface with higher layers, buffer higher layer SDUS for transmission. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC TM protocol instance pointer. -* \param[in] sduP SDU. (A struct rlc_tm_data_req is mapped on sduP->data.) -*/ -void rlc_tm_data_req ( - const protocol_ctxt_t* const ctxt_pP, - void * const rlcP, - mem_block_t * const sduP); - -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h deleted file mode 100644 index b6795d4488b19a11eb7ffa72c7d35984ec972f66..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_tm_entity.h -* \brief This file defines the RLC TM variables stored in a struct called rlc_tm_entity_t. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note The rlc_tm_entity_t structure store protocol variables, statistic variables, allocation variables, buffers and other miscellaneous variables. -* \bug -* \warning -*/ -# ifndef __RLC_TM_ENTITY_H__ -# define __RLC_TM_ENTITY_H__ -//----------------------------------------------------------------------------- -# include "platform_types.h" -#include "common/platform_constants.h" -# include "rlc_tm_structs.h" -# include "rlc_def.h" -//----------------------------------------------------------------------------- -/*! \struct rlc_tm_entity_t -* \brief Structure containing a RLC TM instance protocol variables, allocation variables, buffers and other miscellaneous variables. -*/ -typedef struct rlc_tm_entity { - bool allocation; /*!< \brief Boolean for rlc_tm_entity_t struct allocation. */ - rlc_protocol_state_t protocol_state; /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE, RLC_LOCAL_SUSPEND_STATE. */ - bool is_uplink_downlink; /*!< \brief Is this instance is a transmitter, a receiver or both? */ - bool is_data_plane; /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */ - // for stats and trace purpose : - logical_chan_id_t channel_id; /*!< \brief Transport channel identifier. */ - rb_id_t rb_id; /*!< \brief Radio bearer identifier, for statistics and trace purpose. */ - //----------------------------- - // tranmission - //----------------------------- - // sdu communication; - mem_block_t **input_sdus; /*!< \brief Input SDU buffer (for SDUs coming from upper layers). Should be accessed as an array. */ - mem_block_t *input_sdus_alloc; /*!< \brief Allocated memory for the input SDU buffer (for SDUs coming from upper layers). */ - 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 pdus_to_mac_layer; /*!< \brief PDUs buffered for transmission to MAC layer. */ - sdu_size_t rlc_pdu_size; - rlc_buffer_occupancy_t buffer_occupancy; /*!< \brief Number of bytes contained in input_sdus buffer.*/ - //----------------------------- - // receiver - //----------------------------- - unsigned int output_sdu_size_to_write; /*!< \brief Size of the reassemblied SDU. */ - mem_block_t *output_sdu_in_construction; /*!< \brief Memory area where a complete SDU is reassemblied before being send to upper layers. */ -} rlc_tm_entity_t; -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c deleted file mode 100644 index a838b2a00663e0ebb6706605b1379232da9d51de..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_TM_MODULE 1 -#define RLC_TM_INIT_C 1 -//----------------------------------------------------------------------------- -#include "rlc_tm.h" -#include "LAYER2/MAC/mac_extern.h" -//----------------------------------------------------------------------------- -void config_req_rlc_tm ( - const protocol_ctxt_t* const ctxt_pP, - const srb_flag_t srb_flagP, - const rlc_tm_info_t * const config_tmP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP -) -{ - rlc_union_t *rlc_union_p = NULL; - rlc_tm_entity_t *rlc_p = NULL; - hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); - hashtable_rc_t h_rc; - - h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); - - if (h_rc == HASH_TABLE_OK) { - rlc_p = &rlc_union_p->rlc.tm; - LOG_D(RLC, PROTOCOL_RLC_TM_CTXT_FMT" CONFIG_REQ (is_uplink_downlink=%d) RB %ld\n", - PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_p), - config_tmP->is_uplink_downlink, - rb_idP); - - rlc_tm_init(ctxt_pP, rlc_p); - rlc_p->protocol_state = RLC_DATA_TRANSFER_READY_STATE; - rlc_tm_set_debug_infos(ctxt_pP, rlc_p, srb_flagP, rb_idP, chan_idP); - rlc_tm_configure(ctxt_pP, rlc_p, config_tmP->is_uplink_downlink); - } else { - LOG_E(RLC, PROTOCOL_RLC_TM_CTXT_FMT" CONFIG_REQ RB %ld RLC NOT FOUND\n", - PROTOCOL_RLC_TM_CTXT_ARGS(ctxt_pP, rlc_p), - rb_idP); - } -} - -//----------------------------------------------------------------------------- -void rlc_tm_init ( - const protocol_ctxt_t* const ctxt_pP, - rlc_tm_entity_t * const rlcP -) -{ - int saved_allocation = rlcP->allocation; - memset (rlcP, 0, sizeof (struct rlc_tm_entity)); - rlcP->allocation = saved_allocation; - // TX SIDE - list_init (&rlcP->pdus_to_mac_layer, NULL); - - rlcP->protocol_state = RLC_NULL_STATE; - rlcP->nb_sdu = 0; - rlcP->next_sdu_index = 0; - rlcP->current_sdu_index = 0; - - rlcP->output_sdu_size_to_write = 0; - rlcP->buffer_occupancy = 0; - - // SPARE : not 3GPP - rlcP->size_input_sdus_buffer = 16; - - if ((rlcP->input_sdus_alloc == NULL) && (rlcP->size_input_sdus_buffer > 0)) { - rlcP->input_sdus_alloc = get_free_mem_block (rlcP->size_input_sdus_buffer * sizeof (void *), __func__); - if(rlcP->input_sdus_alloc == NULL) return; - rlcP->input_sdus = (mem_block_t **) (rlcP->input_sdus_alloc->data); - memset (rlcP->input_sdus, 0, rlcP->size_input_sdus_buffer * sizeof (void *)); - } -} - -//----------------------------------------------------------------------------- -void -rlc_tm_reset_state_variables ( - const protocol_ctxt_t* const ctxt_pP, - struct rlc_tm_entity * const rlcP -) -{ - rlcP->output_sdu_size_to_write = 0; - rlcP->buffer_occupancy = 0; - rlcP->nb_sdu = 0; - rlcP->next_sdu_index = 0; - rlcP->current_sdu_index = 0; -} -//----------------------------------------------------------------------------- -void -rlc_tm_cleanup ( - rlc_tm_entity_t * const rlcP -) -{ - int index; - // TX SIDE - list_free (&rlcP->pdus_to_mac_layer); - - if (rlcP->input_sdus_alloc) { - for (index = 0; index < rlcP->size_input_sdus_buffer; index++) { - if (rlcP->input_sdus[index]) { - free_mem_block (rlcP->input_sdus[index], __func__); - } - } - - free_mem_block (rlcP->input_sdus_alloc, __func__); - rlcP->input_sdus_alloc = NULL; - } - - // RX SIDE - if ((rlcP->output_sdu_in_construction)) { - free_mem_block (rlcP->output_sdu_in_construction, __func__); - rlcP->output_sdu_in_construction = NULL; - } - - memset(rlcP, 0, sizeof(rlc_tm_entity_t)); -} - -//----------------------------------------------------------------------------- -void rlc_tm_configure(const protocol_ctxt_t* const ctxt_pP, - rlc_tm_entity_t * const rlcP, - const bool is_uplink_downlinkP) -{ - rlcP->is_uplink_downlink = is_uplink_downlinkP; - rlc_tm_reset_state_variables (ctxt_pP, rlcP); -} - -//----------------------------------------------------------------------------- -void rlc_tm_set_debug_infos( - const protocol_ctxt_t* const ctxt_pP, - rlc_tm_entity_t * const rlcP, - const srb_flag_t srb_flagP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP) -{ - rlcP->rb_id = rb_idP; - rlcP->channel_id = chan_idP; - - if (srb_flagP) { - rlcP->is_data_plane = 0; - } else { - rlcP->is_data_plane = 1; - } -} diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h deleted file mode 100644 index f315a0311ae3badd25a06753b4974abed62b8c38..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_tm_init.h -* \brief This file defines the prototypes of the functions dealing with the control primitives and initialization. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_tm_init_impl_ RLC TM Init Reference Implementation -* @ingroup _rlc_tm_impl_ -* @{ -*/ -# ifndef __RLC_TM_INIT_H__ -# define __RLC_TM_INIT_H__ -//----------------------------------------------------------------------------- -# include "rlc_tm_entity.h" -# include "mem_block.h" -# include "rlc_tm_structs.h" -//# include "rlc.h" -# include "platform_types.h" -//----------------------------------------------------------------------------- - -typedef volatile struct rlc_tm_info_s { - uint8_t is_uplink_downlink; -} rlc_tm_info_t; - - -/*! \fn void config_req_rlc_tm (void config_req_rlc_tm ( - const protocol_ctxt_t* const ctxt_pP, - const srb_flag_t srb_flagP, - const rlc_tm_info_t * const config_tmP, - const rb_id_t rb_idP, - const srb_flag_t srb_flagP) -* \brief Allocate memory for RLC TM instance, reset protocol variables, and set protocol parameters. -* \param[in] srb_flagP Flag to indicate SRB (1) or DRB (0) -* \param[in] config_tmP Configuration parameters for RLC TM instance. -* \param[in] rb_idP Radio bearer identifier. -* \param[in] chan_idP Transport channel identifier. -*/ -void config_req_rlc_tm ( - const protocol_ctxt_t* const ctxt_pP, - const srb_flag_t srb_flagP, - const rlc_tm_info_t * const config_tmP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP); - -/*! \fn void rlc_tm_init (const protocol_ctxt_t* const ctxt_pP, rlc_tm_entity_t * const rlcP) -* \brief Initialize a RLC TM protocol instance, initialize all variables, lists, allocate buffers for making this instance ready to be configured with protocol configuration parameters. After this initialization the RLC TM protocol instance will be in RLC_NULL_STATE state. -* \param[in] rlcP RLC TM protocol instance pointer. -*/ -void rlc_tm_init ( - const protocol_ctxt_t* const ctxt_pP, - rlc_tm_entity_t * const rlcP); - -/*! \fn void rlc_tm_reset_state_variables (const protocol_ctxt_t* const ctxt_pP, rlc_tm_entity_t * const rlcP) -* \brief Reset protocol variables and state variables to initial values. -* \param[in] rlcP RLC TM protocol instance pointer. -*/ -void rlc_tm_reset_state_variables(const protocol_ctxt_t* const ctxt_pP, - rlc_tm_entity_t * const rlcP); - -/*! \fn void rlc_tm_cleanup(rlc_tm_entity_t * const rlcP) -* \brief Free all allocated memory (lists and buffers) previously allocated by this RLC TM instance. -* \param[in] rlcP RLC TM protocol instance pointer. -*/ -void rlc_tm_cleanup(rlc_tm_entity_t * const rlcP); - -/*! \fn void rlc_tm_configure(const protocol_ctxt_t* const ctxt_pP,rlc_tm_entity_t * const rlcP, const bool is_uplink_downlinkP) -* \brief Configure RLC TM protocol parameters. -* \param[in] rlcP RLC TM protocol instance pointer. -* \param[in] is_uplink_downlinkP Is this instance is TRANSMITTER_ONLY, -RECEIVER_ONLY, or TRANSMITTER_AND_RECEIVER. -*/ -void rlc_tm_configure(const protocol_ctxt_t* const ctxt_pP, - rlc_tm_entity_t * const rlcP, - const bool is_uplink_downlinkP); - -/*! \fn void rlc_tm_set_debug_infos(const protocol_ctxt_t* const ctxt_pP, rlc_tm_entity_t * const rlcP, const rb_id_t rb_idP, const srb_flag_t srb_flagP) -* \brief Set debug informations for a RLC TM protocol instance, these informations are only for trace purpose. -* \param[in] rlcP RLC TM protocol instance pointer. -* \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). -* \param[in] rb_idP Radio bearer identifier. -* \param[in] chan_idP Transport channel identifier -*/ -void rlc_tm_set_debug_infos( - const protocol_ctxt_t* const ctxt_pP, - rlc_tm_entity_t * const rlcP, - const srb_flag_t srb_flagP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP); - -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_structs.h b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_structs.h deleted file mode 100644 index ee9d5268d4a25b3ed601aa15465261658e421740..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_structs.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_tm_structs.h -* \brief This file defines structures used inside the RLC TM. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \company Eurecom -* \email: lionel.gauthier@eurecom.fr -* \note -* \bug -* \warning -*/ -# ifndef __RLC_TM_STRUCTS_H__ -# define __RLC_TM_STRUCTS_H__ -# include "platform_types.h" -# include "list.h" -# include "mac_primitives.h" -# include "rlc_primitives.h" -# include "mac_rlc_primitives.h" -//----------------------- -struct rlc_tm_tx_sdu_management { - uint8_t *first_byte; - int32_t sdu_creation_time; - uint16_t sdu_size; -}; -//----------------------- -struct rlc_tm_tx_pdu_management { - uint8_t *first_byte; - uint8_t dummy[MAC_HEADER_MAX_SIZE]; -}; -//----------------------- -struct rlc_tm_rx_pdu_management { - uint8_t *first_byte; -}; -//----------------------- -struct rlc_tm_tx_data_pdu_struct { - union { - struct rlc_tm_tx_pdu_management tx_pdu_mngmnt; - struct mac_tb_req tb_req; - struct mac_tx_tb_management tb_mngt; -# ifdef BYPASS_L1 - struct rlc_tm_rx_pdu_management dummy1; - struct mac_tb_ind dummy2; - struct mac_rx_tb_management dummy3; - struct rlc_indication dummy4; -# endif - } dummy; - uint8_t data[1]; -}; -//----------------------- -struct rlc_tm_data_req_alloc { // alloc enought bytes for sdu mngt also - union { - struct rlc_tm_data_req dummy1; - struct rlc_tm_tx_sdu_management dummy2; - } dummy; -}; -# endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/README b/openair2/LAYER2/RLC/UM_v9.3.0/README deleted file mode 100644 index 05297ce9c0bc1ed2af3ea7b55a29b675940016b1..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/README +++ /dev/null @@ -1,12 +0,0 @@ -####################################### -WHAT IS IMPLEMENTED: -####################################### -All RLC specification 36.322 v9.3.0 concerning UM mode, -except: -The segmentation and the reception of PDU -with a sequence number length of 5 bits. - -####################################### -KNOWN BUGS AND LIMITATION: -####################################### - diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c deleted file mode 100644 index a77280ffd225808a7407aa620bbfbc0afda5e4b1..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c +++ /dev/null @@ -1,579 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_UM_MODULE 1 -#define RLC_UM_C 1 -//----------------------------------------------------------------------------- -//#include "rtos_header.h" -#include "platform_types.h" -#include "common/platform_constants.h" -//----------------------------------------------------------------------------- -#if ENABLE_ITTI - #include "intertask_interface.h" -#endif -#include "assertions.h" -#include "rlc_um.h" -#include "list.h" -#include "rlc_primitives.h" -#include "mac_primitives.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" - - -#include "rlc_um_very_simple_test.h" - -//----------------------------------------------------------------------------- -void rlc_um_stat_req (rlc_um_entity_t *rlc_pP, - unsigned int *stat_tx_pdcp_sdu, - unsigned int *stat_tx_pdcp_bytes, - unsigned int *stat_tx_pdcp_sdu_discarded, - unsigned int *stat_tx_pdcp_bytes_discarded, - unsigned int *stat_tx_data_pdu, - unsigned int *stat_tx_data_bytes, - unsigned int *stat_rx_pdcp_sdu, - unsigned int *stat_rx_pdcp_bytes, - unsigned int *stat_rx_data_pdus_duplicate, - unsigned int *stat_rx_data_bytes_duplicate, - unsigned int *stat_rx_data_pdu, - unsigned int *stat_rx_data_bytes, - unsigned int *stat_rx_data_pdu_dropped, - unsigned int *stat_rx_data_bytes_dropped, - unsigned int *stat_rx_data_pdu_out_of_window, - unsigned int *stat_rx_data_bytes_out_of_window, - unsigned int *stat_timer_reordering_timed_out) { - *stat_tx_pdcp_sdu = rlc_pP->stat_tx_pdcp_sdu; - *stat_tx_pdcp_bytes = rlc_pP->stat_tx_pdcp_bytes; - *stat_tx_pdcp_sdu_discarded = rlc_pP->stat_tx_pdcp_sdu_discarded; - *stat_tx_pdcp_bytes_discarded = rlc_pP->stat_tx_pdcp_bytes_discarded; - *stat_tx_data_pdu = rlc_pP->stat_tx_data_pdu; - *stat_tx_data_bytes = rlc_pP->stat_tx_data_bytes; - *stat_rx_pdcp_sdu = rlc_pP->stat_rx_pdcp_sdu; - *stat_rx_pdcp_bytes = rlc_pP->stat_rx_pdcp_bytes; - *stat_rx_data_pdus_duplicate = rlc_pP->stat_rx_data_pdus_duplicate; - *stat_rx_data_bytes_duplicate = rlc_pP->stat_rx_data_bytes_duplicate; - *stat_rx_data_pdu = rlc_pP->stat_rx_data_pdu; - *stat_rx_data_bytes = rlc_pP->stat_rx_data_bytes; - *stat_rx_data_pdu_dropped = rlc_pP->stat_rx_data_pdu_dropped; - *stat_rx_data_bytes_dropped = rlc_pP->stat_rx_data_bytes_dropped; - *stat_rx_data_pdu_out_of_window = rlc_pP->stat_rx_data_pdu_out_of_window; - *stat_rx_data_bytes_out_of_window = rlc_pP->stat_rx_data_bytes_out_of_window; - *stat_timer_reordering_timed_out = rlc_pP->stat_timer_reordering_timed_out; -} -//----------------------------------------------------------------------------- -uint32_t -rlc_um_get_buffer_occupancy (rlc_um_entity_t *rlc_pP) { - if (rlc_pP->buffer_occupancy > 0) { - return rlc_pP->buffer_occupancy; - } else { - return 0; - } -} -//----------------------------------------------------------------------------- -void -rlc_um_get_pdus (const protocol_ctxt_t *const ctxt_pP, void *argP) { - rlc_um_entity_t *rlc_p = (rlc_um_entity_t *) argP; - - switch (rlc_p->protocol_state) { - case RLC_NULL_STATE: - // from 3GPP TS 25.322 V9.2.0 p43 - // In the NULL state the RLC entity does not exist and therefore it is - // not possible to transfer any data through it. - // Upon reception of a CRLC-CONFIG-Req from upper layer indicating - // establishment, the RLC entity: - // - is created; and - // - enters the DATA_TRANSFER_READY state. - break; - - case RLC_DATA_TRANSFER_READY_STATE: - - // from 3GPP TS 25.322 V9.2.0 p43-44 - // In the DATA_TRANSFER_READY state, unacknowledged mode data can be - // exchanged between the entities according to subclause 11.2. - // Upon reception of a CRLC-CONFIG-Req from upper layer indicating - // release, the RLC entity: - // -enters the NULL state; and - // -is considered as being terminated. - // Upon reception of a CRLC-CONFIG-Req from upper layer indicating - // modification, the RLC entity: - // - stays in the DATA_TRANSFER_READY state; - // - modifies only the protocol parameters and timers as indicated by - // upper layers. - // Upon reception of a CRLC-SUSPEND-Req from upper layers, the RLC - // entity: - // - enters the LOCAL_SUSPEND state. - - // SEND DATA TO MAC - if (rlc_p->tx_sn_length == 10) { - rlc_um_segment_10 (ctxt_pP, rlc_p); - } - - if (rlc_p->tx_sn_length == 5) { - rlc_um_segment_5 (ctxt_pP, rlc_p); - } - - break; - - case RLC_LOCAL_SUSPEND_STATE: - // from 3GPP TS 25.322 V9.2.0 p44 - // In the LOCAL_SUSPEND state, the RLC entity is suspended, i.e. it does - // not send UMD PDUs with "Sequence Number" greater than or equal to a - // certain specified value (see subclause 9.7.5). - // Upon reception of a CRLC-CONFIG-Req from upper layer indicating - // release, the RLC entity: - // - enters the NULL state; and - // - is considered as being terminated. - // Upon reception of a CRLC-RESUME-Req from upper layers, the RLC entity: - // - enters the DATA_TRANSFER_READY state; and - // - resumes the data transmission. - // Upon reception of a CRLC-CONFIG-Req from upper layer indicating - // modification, the RLC entity: - // - stays in the LOCAL_SUSPEND state; - // - modifies only the protocol parameters and timers as indicated by - // upper layers. - // TO DO TAKE CARE OF SN : THE IMPLEMENTATION OF THIS FUNCTIONNALITY IS NOT CRITICAL - break; - - default: - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" MAC_DATA_REQ UNKNOWN PROTOCOL STATE %02X hex\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), - rlc_p->protocol_state); - } -} - -//----------------------------------------------------------------------------- -void -rlc_um_rx (const protocol_ctxt_t *const ctxt_pP, void *argP, struct mac_data_ind data_indP) { - rlc_um_entity_t *l_rlc_p = (rlc_um_entity_t *) argP; - char message_string[10000]; - mem_block_t *tb_p; - int16_t tb_size_in_bytes; - rlc_um_pdu_info_t pdu_info; - int index; - int octet_index; - - switch (l_rlc_p->protocol_state) { - case RLC_NULL_STATE: - // from 3GPP TS 25.322 V9.2.0 p43 - // In the NULL state the RLC entity does not exist and therefore it is - // not possible to transfer any data through it. - // Upon reception of a CRLC-CONFIG-Req from upper layer indicating - // establishment, the RLC entity: - // - is created; and - // - enters the DATA_TRANSFER_READY state. - LOG_I(RLC, PROTOCOL_RLC_UM_CTXT_FMT" ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,l_rlc_p)); - - if (data_indP.data.nb_elements > 0) { - tb_p = data_indP.data.head; - - while (tb_p != NULL) { - tb_size_in_bytes = ((struct mac_tb_ind *) (tb_p->data))->size; - rlc_um_get_pdu_infos(ctxt_pP,l_rlc_p,(rlc_um_pdu_sn_10_t *) ((struct mac_tb_ind *) (tb_p->data))->data_ptr, tb_size_in_bytes, &pdu_info, l_rlc_p->rx_sn_length); - tb_p = tb_p->next; - } - } - - list_free (&data_indP.data); - break; - - case RLC_DATA_TRANSFER_READY_STATE: - // from 3GPP TS 25.322 V9.2.0 p43-44 - // In the DATA_TRANSFER_READY state, unacknowledged mode data can be - // exchanged between the entities according to subclause 11.2. - // Upon reception of a CRLC-CONFIG-Req from upper layer indicating - // release, the RLC entity: - // -enters the NULL state; and - // -is considered as being terminated. - // Upon reception of a CRLC-CONFIG-Req from upper layer indicating - // modification, the RLC entity: - // - stays in the DATA_TRANSFER_READY state; - // - modifies only the protocol parameters and timers as indicated by - // upper layers. - // Upon reception of a CRLC-SUSPEND-Req from upper layers, the RLC - // entity: - // - enters the LOCAL_SUSPEND state. - data_indP.tb_size = data_indP.tb_size >> 3; - - if (data_indP.data.nb_elements > 0 && (LOG_DEBUGFLAG(DEBUG_RLC))) { - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" MAC_DATA_IND %d TBs\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,l_rlc_p), - data_indP.data.nb_elements); - tb_p = data_indP.data.head; - - while (tb_p != NULL) { - tb_size_in_bytes = ((struct mac_tb_ind *) (tb_p->data))->size; - rlc_um_get_pdu_infos(ctxt_pP, - l_rlc_p,(rlc_um_pdu_sn_10_t *) ((struct mac_tb_ind *) (tb_p->data))->data_ptr, - tb_size_in_bytes, - &pdu_info, - l_rlc_p->rx_sn_length); - - if (LOG_DEBUGFLAG(DEBUG_RLC)) { - message_string_size = 0; - message_string_size += sprintf(&message_string[message_string_size], "Bearer : %ld\n", l_rlc_p->rb_id); - message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", tb_size_in_bytes); - message_string_size += sprintf(&message_string[message_string_size], "Header size : %u\n", pdu_info.header_size); - message_string_size += sprintf(&message_string[message_string_size], "Payload size: %u\n", pdu_info.payload_size); - message_string_size += sprintf(&message_string[message_string_size], "PDU type : RLC UM DATA IND: UMD PDU\n\n"); - message_string_size += sprintf(&message_string[message_string_size], "Header :\n"); - message_string_size += sprintf(&message_string[message_string_size], " FI : %u\n", pdu_info.fi); - message_string_size += sprintf(&message_string[message_string_size], " E : %u\n", pdu_info.e); - message_string_size += sprintf(&message_string[message_string_size], " SN : %u\n", pdu_info.sn); - - if (pdu_info.e) { - message_string_size += sprintf(&message_string[message_string_size], "\nHeader extension : \n"); - - for (index=0; index < pdu_info.num_li; index++) { - message_string_size += sprintf(&message_string[message_string_size], " LI : %u\n", pdu_info.li_list[index]); - } - } - - message_string_size += sprintf(&message_string[message_string_size], "\nPayload : \n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - message_string_size += sprintf(&message_string[message_string_size], " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - - for (octet_index = 0; octet_index < pdu_info.payload_size; octet_index++) { - if ((octet_index % 16) == 0) { - if (octet_index != 0) { - message_string_size += sprintf(&message_string[message_string_size], " |\n"); - } - - message_string_size += sprintf(&message_string[message_string_size], " %04d |", octet_index); - } - - /* - * Print every single octet in hexadecimal form - */ - message_string_size += sprintf(&message_string[message_string_size], " %02x", pdu_info.payload[octet_index]); - /* - * Align newline and pipes according to the octets in groups of 2 - */ - } - - /* - * Append enough spaces and put final pipe - */ - for (index = octet_index; index < 16; ++index) { - message_string_size += sprintf(&message_string[message_string_size], " "); - } - - message_string_size += sprintf(&message_string[message_string_size], " |\n"); - LOG_UI(RLC, "%s|\n", message_string); - } - - tb_p = tb_p->next; - } - } - - rlc_um_receive (ctxt_pP, l_rlc_p, data_indP); - break; - - case RLC_LOCAL_SUSPEND_STATE: - // from 3GPP TS 25.322 V9.2.0 p44 - // In the LOCAL_SUSPEND state, the RLC entity is suspended, i.e. it does - // not send UMD PDUs with "Sequence Number" greater than or equal to a - // certain specified value (see subclause 9.7.5). - // Upon reception of a CRLC-CONFIG-Req from upper layer indicating - // release, the RLC entity: - // - enters the NULL state; and - // - is considered as being terminated. - // Upon reception of a CRLC-RESUME-Req from upper layers, the RLC entity: - // - enters the DATA_TRANSFER_READY state; and - // - resumes the data transmission. - // Upon reception of a CRLC-CONFIG-Req from upper layer indicating - // modification, the RLC entity: - // - stays in the LOCAL_SUSPEND state; - // - modifies only the protocol parameters and timers as indicated by - // upper layers. - LOG_I(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RLC_LOCAL_SUSPEND_STATE\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,l_rlc_p)); - list_free (&data_indP.data); - break; - - default: - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TX UNKNOWN PROTOCOL STATE %02X hex\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,l_rlc_p), - l_rlc_p->protocol_state); - list_free (&data_indP.data); - } -} - -//----------------------------------------------------------------------------- -struct mac_status_resp -rlc_um_mac_status_indication (const protocol_ctxt_t *const ctxt_pP, void *rlc_pP, struct mac_status_ind tx_statusP,const eNB_flag_t enb_flagP) { - struct mac_status_resp status_resp; - uint16_t sdu_size = 0; - uint16_t sdu_remaining_size = 0; - int32_t diff_time=0; - rlc_um_entity_t *rlc_p = (rlc_um_entity_t *) rlc_pP; - mem_block_t *mb_p = NULL; - status_resp.buffer_occupancy_in_pdus = 0; - status_resp.buffer_occupancy_in_bytes = 0; - status_resp.head_sdu_remaining_size_to_send = 0; - status_resp.head_sdu_creation_time = 0; - status_resp.head_sdu_is_segmented = 0; - - if (rlc_pP) { - status_resp.rlc_info.rlc_protocol_state = rlc_p->protocol_state; - rlc_um_check_timer_dar_time_out(ctxt_pP, rlc_p); - status_resp.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy (rlc_p); - - if ((status_resp.buffer_occupancy_in_bytes > 0) && ((mb_p = list_get_head(&rlc_p->input_sdus)) != NULL)) { - if (enb_flagP == ENB_FLAG_YES) { - /* For eNB: add minimum RLC UM header size for the scheduler */ - /* For UE : RLC header part is not taken into account for BSR reporting (cf 36.321) */ - 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 = ctxt_pP->frame - ((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 + ctxt_pP->frame) ; - //msg("rlc_p status for ctxt_pP->frame %d diff time %d resp %d\n", ctxt_pP->frame, diff_time,status_resp.head_sdu_creation_time) ; - 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_is_segmented = 0; - } else { - status_resp.head_sdu_is_segmented = 1; - } - } else { - } - - status_resp.rlc_info.rlc_protocol_state = rlc_p->protocol_state; - - if (LOG_DEBUGFLAG(DEBUG_RLC)) { - if (( rlc_p->rb_id > 0) && (status_resp.buffer_occupancy_in_bytes > 0)) { - LOG_UI(RLC, PROTOCOL_RLC_UM_CTXT_FMT"MAC_STATUS_INDICATION (DATA) -> %d bytes available\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), - status_resp.buffer_occupancy_in_bytes); - - if ((tx_statusP.tx_status == MAC_TX_STATUS_SUCCESSFUL) && (tx_statusP.no_pdu)) { - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" MAC_STATUS_INDICATION TX STATUS SUCCESSFUL %d PDUs\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), - tx_statusP.no_pdu); - } - - if ((tx_statusP.tx_status == MAC_TX_STATUS_UNSUCCESSFUL) && (tx_statusP.no_pdu)) { - LOG_UI(RLC, PROTOCOL_RLC_UM_CTXT_FMT" MAC_STATUS_INDICATION TX STATUS UNSUCCESSFUL %d PDUs\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), - tx_statusP.no_pdu); - } - } - } - } else { - LOG_E(RLC, "[RLC] rlc_um_mac_status_indication RLC NULL!!!\n"); - } - - return status_resp; -} - -//----------------------------------------------------------------------------- -struct mac_data_req -rlc_um_mac_data_request (const protocol_ctxt_t *const ctxt_pP, void *rlc_pP,const eNB_flag_t enb_flagP) { - struct mac_data_req data_req; - int16_t tb_size_in_bytes; - mem_block_t *tb_p; - char message_string[10000]; - size_t message_string_size = 0; - rlc_um_pdu_info_t pdu_info; - int octet_index, index; - rlc_um_entity_t *l_rlc_p = (rlc_um_entity_t *) rlc_pP; - rlc_um_get_pdus(ctxt_pP, l_rlc_p); - list_init (&data_req.data, NULL); - list_add_list (&l_rlc_p->pdus_to_mac_layer, &data_req.data); - - if (enb_flagP) { - // redundant in UE MAC Tx processing and not used in eNB scheduler ... - data_req.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy (l_rlc_p); - - if (data_req.buffer_occupancy_in_bytes > 0) { - data_req.buffer_occupancy_in_bytes += l_rlc_p->tx_header_min_length_in_bytes; - } - } - - data_req.rlc_info.rlc_protocol_state = l_rlc_p->protocol_state; - - if (data_req.data.nb_elements > 0) { - tb_p = data_req.data.head; - - while (tb_p != NULL) { - tb_size_in_bytes = ((struct mac_tb_req *) (tb_p->data))->tb_size; - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" MAC_DATA_REQUEST TB SIZE %u\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,l_rlc_p), - ((struct mac_tb_req *) (tb_p->data))->tb_size); - l_rlc_p->stat_tx_data_pdu += 1; - l_rlc_p->stat_tx_data_bytes += tb_size_in_bytes; - - //AssertFatal( tb_size_in_bytes > 0 , "RLC UM PDU LENGTH %d", tb_size_in_bytes); - if(tb_size_in_bytes <= 0) { - LOG_E(RLC, "RLC UM PDU LENGTH %d\n", tb_size_in_bytes); - tb_p = tb_p->next; - continue; - } - - if (LOG_DEBUGFLAG(DEBUG_RLC) ) { - rlc_um_get_pdu_infos(ctxt_pP, l_rlc_p,(rlc_um_pdu_sn_10_t *) ((struct mac_tb_req *) (tb_p->data))->data_ptr, tb_size_in_bytes, &pdu_info, l_rlc_p->rx_sn_length); - - message_string_size = 0; - message_string_size += sprintf(&message_string[message_string_size], "Bearer : %ld\n", l_rlc_p->rb_id); - message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", tb_size_in_bytes); - message_string_size += sprintf(&message_string[message_string_size], "Header size : %u\n", pdu_info.header_size); - message_string_size += sprintf(&message_string[message_string_size], "Payload size: %u\n", pdu_info.payload_size); - message_string_size += sprintf(&message_string[message_string_size], "PDU type : RLC UM DATA IND: UMD PDU\n\n"); - message_string_size += sprintf(&message_string[message_string_size], "Header :\n"); - message_string_size += sprintf(&message_string[message_string_size], " FI : %u\n", pdu_info.fi); - message_string_size += sprintf(&message_string[message_string_size], " E : %u\n", pdu_info.e); - message_string_size += sprintf(&message_string[message_string_size], " SN : %u\n", pdu_info.sn); - - if (pdu_info.e) { - message_string_size += sprintf(&message_string[message_string_size], "\nHeader extension : \n"); - - for (index=0; index < pdu_info.num_li; index++) { - message_string_size += sprintf(&message_string[message_string_size], " LI : %u\n", pdu_info.li_list[index]); - } - } - - message_string_size += sprintf(&message_string[message_string_size], "\nPayload : \n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - message_string_size += sprintf(&message_string[message_string_size], " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - - for (octet_index = 0; octet_index < pdu_info.payload_size; octet_index++) { - if ((octet_index % 16) == 0) { - if (octet_index != 0) { - message_string_size += sprintf(&message_string[message_string_size], " |\n"); - } - - message_string_size += sprintf(&message_string[message_string_size], " %04d |", octet_index); - } - - /* - * Print every single octet in hexadecimal form - */ - message_string_size += sprintf(&message_string[message_string_size], " %02x", pdu_info.payload[octet_index]); - /* - * Align newline and pipes according to the octets in groups of 2 - */ - } - - /* - * Append enough spaces and put final pipe - */ - for (index = octet_index; index < 16; ++index) { - message_string_size += sprintf(&message_string[message_string_size], " "); - } - - message_string_size += sprintf(&message_string[message_string_size], " |\n"); - LOG_UI(RLC, "%s\n", message_string); - } /* LOG_DEBUGFLAG(DEBUG_RLC) */ - - tb_p = tb_p->next; - } /* while (tb_p != NULL) */ - } /* if (data_req.data.nb_elements > 0) */ - - data_req.buffer_occupancy_in_pdus = 0; - return data_req; -} - -//----------------------------------------------------------------------------- -void -rlc_um_mac_data_indication (const protocol_ctxt_t *const ctxt_pP, void *rlc_pP, struct mac_data_ind data_indP) { - rlc_um_rx (ctxt_pP, rlc_pP, data_indP); - rlc_um_check_timer_dar_time_out(ctxt_pP, rlc_pP); -} - -//----------------------------------------------------------------------------- -void -rlc_um_data_req (const protocol_ctxt_t *const ctxt_pP, void *rlc_pP, mem_block_t *sdu_pP) { - rlc_um_entity_t *rlc_p = (rlc_um_entity_t *) rlc_pP; - uint16_t data_offset; - uint16_t data_size; - size_t message_string_size = 0; - int octet_index, index; - char message_string[7000]; - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RLC_UM_DATA_REQ size %d Bytes, BO %d , NB SDU %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), - ((struct rlc_um_data_req *) (sdu_pP->data))->data_size, - rlc_p->buffer_occupancy, - rlc_p->input_sdus.nb_elements); - // 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->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 = ctxt_pP->frame; - //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; - - if (LOG_DEBUGFLAG(DEBUG_RLC) ) { - data_offset = sizeof (struct rlc_um_data_req_alloc); - data_size = ((struct rlc_um_tx_sdu_management *)(sdu_pP->data))->sdu_size; - message_string_size += sprintf(&message_string[message_string_size], "Bearer : %ld\n", rlc_p->rb_id); - message_string_size += sprintf(&message_string[message_string_size], "SDU size : %u\n", data_size); - message_string_size += sprintf(&message_string[message_string_size], "\nPayload : \n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - message_string_size += sprintf(&message_string[message_string_size], " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"); - message_string_size += sprintf(&message_string[message_string_size], "------+-------------------------------------------------|\n"); - - for (octet_index = 0; octet_index < data_size; octet_index++) { - if ((octet_index % 16) == 0) { - if (octet_index != 0) { - message_string_size += sprintf(&message_string[message_string_size], " |\n"); - } - - message_string_size += sprintf(&message_string[message_string_size], " %04d |", octet_index); - } - - /* - * Print every single octet in hexadecimal form - */ - message_string_size += sprintf(&message_string[message_string_size], " %02x", ((uint8_t *)(&sdu_pP->data[data_offset]))[octet_index]); - /* - * Align newline and pipes according to the octets in groups of 2 - */ - } - - /* - * Append enough spaces and put final pipe - */ - for (index = octet_index; index < 16; ++index) { - message_string_size += sprintf(&message_string[message_string_size], " "); - } - - LOG_UI(RLC, "%s|\n", message_string); - } - - RLC_UM_MUTEX_LOCK(&rlc_p->lock_input_sdus, ctxt_pP, rlc_p); - rlc_p->buffer_occupancy += ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_size; - list_add_tail_eurecom(sdu_pP, &rlc_p->input_sdus); - RLC_UM_MUTEX_UNLOCK(&rlc_p->lock_input_sdus); - - LOG_T(RLC, PROTOCOL_RLC_UM_CTXT_FMT" BO %d , NB SDU %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), - rlc_p->buffer_occupancy, - rlc_p->input_sdus.nb_elements); -} diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h deleted file mode 100644 index bd04ff3ece65cb43c275a7cd79ee8b0ac4224b3e..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_um.h -* \brief This file, and only this file must be included by code that interact with RLC UM layer. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_um_impl_ RLC UM Layer Reference Implementation -* @ingroup _rlc_impl_ -* @{ -*/ -# ifndef __RLC_UM_H__ -# define __RLC_UM_H__ -# include <errno.h> -# include "platform_types.h" -# include "rlc_def.h" -# include "rlc_def_lte.h" -# include "rlc_um_constants.h" -# include "rlc_um_structs.h" -# include "rlc_um_entity.h" -# include "mem_block.h" -# include "rlc_um_control_primitives.h" -# include "rlc_um_dar.h" -# include "rlc_um_fsm.h" -# include "rlc_um_reassembly.h" -# include "rlc_um_receiver.h" -# include "rlc_um_segment.h" -# include "rlc_um_test.h" - -#define PROTOCOL_RLC_UM_CTXT_FMT PROTOCOL_CTXT_FMT"[%s %02ld] %s()" -#define PROTOCOL_RLC_UM_CTXT_ARGS(CTXT_Pp, rLC_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\ - (rLC_Pp->is_data_plane) ? "DRB UM" : "SRB UM",\ - rLC_Pp->rb_id,\ - __FUNCTION__ - -#if defined(TRACE_RLC_MUTEX) -#define RLC_UM_MUTEX_LOCK(mUTEX, cTXT, rLC) \ - do {\ - int pmtl_rc = pthread_mutex_trylock(mUTEX);\ - if (pmtl_rc != 0){\ - if (pmtl_rc == EBUSY) {\ - pthread_mutex_lock(mUTEX);\ - }\ - }\ - } while (0); -#else -#define RLC_UM_MUTEX_LOCK(mUTEX, cTXT, rLC) pthread_mutex_lock(mUTEX) -#endif - -#define RLC_UM_MUTEX_UNLOCK(mUTEX) pthread_mutex_unlock(mUTEX) - -/*! \fn void rlc_um_stat_req (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, - unsigned int* stat_tx_pdcp_sdu, - unsigned int* stat_tx_pdcp_bytes, - unsigned int* stat_tx_pdcp_sdu_discarded, - unsigned int* stat_tx_pdcp_bytes_discarded, - unsigned int* stat_tx_data_pdu, - unsigned int* stat_tx_data_bytes, - unsigned int* stat_rx_pdcp_sdu, - unsigned int* stat_rx_pdcp_bytes, - unsigned int* stat_rx_data_pdus_duplicate, - unsigned int* stat_rx_data_bytes_duplicate, - unsigned int* stat_rx_data_pdu, - unsigned int* stat_rx_data_bytes, - unsigned int* stat_rx_data_pdu_dropped, - unsigned int* stat_rx_data_bytes_dropped, - unsigned int* stat_rx_data_pdu_out_of_window, - unsigned int* stat_rx_data_bytes_out_of_window, - unsigned int* stat_timer_reordering_timed_out) -* \brief Request TX and RX statistics of a RLC AM protocol instance. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[out] stat_tx_pdcp_sdu Number of SDUs coming from upper layers. -* \param[out] stat_tx_pdcp_bytes Number of bytes coming from upper layers. -* \param[out] stat_tx_pdcp_sdu_discarded Number of discarded SDUs coming from upper layers. -* \param[out] stat_tx_pdcp_bytes_discarded Number of discarded bytes coming from upper layers. -* \param[out] stat_tx_data_pdu Number of transmitted data PDUs to lower layers. -* \param[out] stat_tx_data_bytes Number of transmitted data bytes to lower layers. -* \param[out] stat_rx_pdcp_sdu Number of SDUs delivered to upper layers. -* \param[out] stat_rx_pdcp_bytes Number of bytes delivered to upper layers. -* \param[out] stat_rx_data_pdus_duplicate Number of duplicate PDUs received. -* \param[out] stat_rx_data_bytes_duplicate Number of duplicate bytes received. -* \param[out] stat_rx_data_pdu Number of received PDUs from lower layers. -* \param[out] stat_rx_data_bytes Number of received bytes from lower layers. -* \param[out] stat_rx_data_pdu_dropped Number of received PDUs from lower layers, then dropped. -* \param[out] stat_rx_data_bytes_dropped Number of received bytes from lower layers, then dropped. -* \param[out] stat_rx_data_pdu_out_of_window Number of data PDUs received out of the receive window. -* \param[out] stat_rx_data_bytes_out_of_window Number of data bytes received out of the receive window. -* \param[out] stat_timer_reordering_timed_out Number of times the timer "reordering" has timed-out. -*/ -void rlc_um_stat_req (rlc_um_entity_t *rlc_pP, - unsigned int* stat_tx_pdcp_sdu, - unsigned int* stat_tx_pdcp_bytes, - unsigned int* stat_tx_pdcp_sdu_discarded, - unsigned int* stat_tx_pdcp_bytes_discarded, - unsigned int* stat_tx_data_pdu, - unsigned int* stat_tx_data_bytes, - unsigned int* stat_rx_pdcp_sdu, - unsigned int* stat_rx_pdcp_bytes, - unsigned int* stat_rx_data_pdus_duplicate, - unsigned int* stat_rx_data_bytes_duplicate, - unsigned int* stat_rx_data_pdu, - unsigned int* stat_rx_data_bytes, - unsigned int* stat_rx_data_pdu_dropped, - unsigned int* stat_rx_data_bytes_dropped, - unsigned int* stat_rx_data_pdu_out_of_window, - unsigned int* stat_rx_data_bytes_out_of_window, - unsigned int* stat_timer_reordering_timed_out); - -/*! \fn void rlc_um_get_pdus (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP) -* \brief Request the segmentation of SDUs based on status previously sent by MAC. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -*/ -void -rlc_um_get_pdus (const protocol_ctxt_t* const ctxt_pP, void *argP); -/*! \fn void rlc_um_rx (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, struct mac_data_ind data_indication) -* \brief Process the received PDUs from lower layer. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] data_indication PDUs from MAC. -*/ -void -rlc_um_rx (const protocol_ctxt_t* const ctxt_pP, void *argP, struct mac_data_ind data_indP); -/*! \fn struct mac_status_resp rlc_um_mac_status_indication (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, struct mac_status_ind tx_statusP) -* \brief Request the maximum number of bytes that can be served by RLC instance to MAC and fix the amount of bytes requested by MAC for next RLC transmission. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] tx_statusP Transmission status given by MAC on previous MAC transmission of the PDU. -* \return The maximum number of bytes that can be served by RLC instance to MAC. -*/ -struct mac_status_resp -rlc_um_mac_status_indication (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, struct mac_status_ind tx_statusP,const eNB_flag_t enb_flagP); - -/*! \fn struct mac_data_req rlc_um_mac_data_request (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP,const eNB_flag_t enb_flagP) -* \brief Gives PDUs to lower layer MAC. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] enb_flagP eNB or UE flag. -* \return A PDU of the previously requested number of bytes, and the updated maximum number of bytes that can be served by RLC instance to MAC for next RLC transmission. -*/ -struct mac_data_req -rlc_um_mac_data_request (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP,const eNB_flag_t enb_flagP); - -/*! \fn void rlc_um_mac_data_indication (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP,struct mac_data_ind data_indP) -* \brief Receive PDUs from lower layer MAC. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] data_indP PDUs from MAC. -*/ - -/*! \fn uint32_t rlc_um_get_buffer_occupancy (rlc_um_entity_t *rlc_pP) -* \brief Gets Tx Buffer Occupancy. -* \param[in] rlc_pP RLC UM protocol instance pointer.) -*/ -uint32_t rlc_um_get_buffer_occupancy (rlc_um_entity_t *rlc_pP); - -/*! \fn void rlc_um_data_req (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, mem_block_t *sduP) -* \brief Interface with higher layers, buffer higher layer SDUS for transmission. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] sduP SDU. (A struct rlc_um_data_req is mapped on sduP->data.) -*/ -void -rlc_um_mac_data_indication (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, struct mac_data_ind data_indP); -void -rlc_um_data_req (const protocol_ctxt_t *const ctxt_pP, void *rlc_pP, mem_block_t *sdu_pP) ; -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_constants.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_constants.h deleted file mode 100644 index 5f210dbe7b08bdb4c413b54e01abd4eaff1ce6d9..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_constants.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_um_constants.h -* \brief This file defines constant values used inside RLC UM. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** -* @addtogroup _rlc_um_internal_impl_ -* @{ -*/ -# ifndef __RLC_UM_CONSTANTS_H__ -# define __RLC_UM_CONSTANTS_H__ - -/** The sequence numbering modulo (10 bits). */ -# define RLC_UM_SN_10_BITS_MODULO 1024 -/** The sequence numbering binary mask (10 bits). */ -# define RLC_UM_SN_10_BITS_MASK 0x03FF -/** UM_Window_Size = 512 when a 10 bit SN is configured. */ -# define RLC_UM_WINDOW_SIZE_SN_10_BITS 512 -/** The sequence numbering modulo (5 bits). */ -# define RLC_UM_SN_5_BITS_MODULO 32 -/** The sequence numbering binary mask (5 bits). */ -# define RLC_UM_SN_5_BITS_MASK 0x1F -/** UM_Window_Size = 16 when a 5 bit SN is configured. */ -# define RLC_UM_WINDOW_SIZE_SN_5_BITS 16 -// This constant is used by the receiving UM RLC entity to define SNs of those -// UMD PDUs that can be received without causing an advancement of the -// receiving window. UM_Window_Size = 16 when a 5 bit SN is configured, -// UM_Window_Size = 512 when a 10 bit SN is configured and UM_Window_Size = 0 -// when the receiving UM RLC entity is configured for MCCH or MTCH. -// li field (values shifted 1 bit left) -# define RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU 128 -//---------------------------------------------------------- -// Events defined for state model of the acknowledged mode entity -/** Internal event defined for state model of the RLC UM. */ -# define RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_NULL_STATE_EVENT 0x00 - -/** Internal event defined for state model of the RLC UM. */ -# define RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT 0x01 - -/** Internal event defined for state model of the RLC UM. */ -# define RLC_UM_RECEIVE_CRLC_SUSPEND_REQ_EVENT 0x10 - -/** Internal event defined for state model of the RLC UM. */ -# define RLC_UM_TRANSMIT_CRLC_SUSPEND_CNF_EVENT 0x11 - -/** Internal event defined for state model of the RLC UM. */ -# define RLC_UM_RECEIVE_CRLC_RESUME_REQ_EVENT 0x12 - -/** Marker in RX buffer meaning that a PDU has been received. */ -# define RLC_UM_PDU_PREVIOUSLY_RECEIVED 0x01 -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c deleted file mode 100644 index f2cb4f09b1e3227851a004c8d0271021ab101523..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_UM_MODULE 1 -#define RLC_UM_CONTROL_PRIMITIVES_C 1 -#include "platform_types.h" -#include "assertions.h" -//----------------------------------------------------------------------------- -#include "rlc_um.h" -#include "rlc_primitives.h" -#include "list.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" - -#include "rlc_um_control_primitives.h" -#include "LTE_T-Reordering.h" - -//----------------------------------------------------------------------------- -void config_req_rlc_um ( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const rlc_um_info_t *const config_um_pP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP) { - rlc_union_t *rlc_union_p = NULL; - rlc_um_entity_t *rlc_p = NULL; - hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); - hashtable_rc_t h_rc; - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - if (h_rc == HASH_TABLE_OK) { - rlc_p = &rlc_union_p->rlc.um; - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" CONFIG_REQ timer_reordering=%d sn_field_length=%d is_mXch=%d RB %ld\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), - config_um_pP->timer_reordering, - config_um_pP->sn_field_length, - config_um_pP->is_mXch, - rb_idP); - rlc_um_init(ctxt_pP, rlc_p); - - if (rlc_um_fsm_notify_event (ctxt_pP, rlc_p, RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT)) { - rlc_um_set_debug_infos(ctxt_pP, rlc_p, srb_flagP, rb_idP, chan_idP); - rlc_um_configure( - ctxt_pP, - rlc_p, - config_um_pP->timer_reordering, - config_um_pP->sn_field_length, - config_um_pP->sn_field_length, - config_um_pP->is_mXch); - } - } else { - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" CONFIG_REQ RB %ld RLC UM NOT FOUND\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), - rb_idP); - } -} -//----------------------------------------------------------------------------- -const uint32_t t_Reordering_tab[32] = {0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,110,120,130,140,150,160,170,180,190,200,1600}; - - -void config_req_rlc_um_asn1 ( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t mbms_flagP, - const mbms_session_id_t mbms_session_idP, - const mbms_service_id_t mbms_service_idP, - const LTE_UL_UM_RLC_t *const ul_rlc_pP, - const LTE_DL_UM_RLC_t *const dl_rlc_pP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP, - const uint32_t sourceL2Id, - const uint32_t destinationL2Id -) { - uint32_t ul_sn_FieldLength = 0; - uint32_t dl_sn_FieldLength = 0; - uint32_t t_Reordering = 0; - rlc_union_t *rlc_union_p = NULL; - rlc_um_entity_t *rlc_p = NULL; - hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); - hashtable_rc_t h_rc; - - if (mbms_flagP) { - //AssertFatal(dl_rlc_pP, "No RLC UM DL config"); - if(dl_rlc_pP == NULL) { - LOG_E(RLC, "No RLC UM DL config\n"); - return; - } - - //AssertFatal(ul_rlc_pP == NULL, "RLC UM UL config present"); - if(ul_rlc_pP != NULL) { - LOG_E(RLC, "RLC UM UL config present\n"); - return; - } - - key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_service_idP, mbms_session_idP); - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - //AssertFatal (h_rc == HASH_TABLE_OK, "RLC NOT FOUND enb id %u rnti %i enb flag %u service id %u, session id %u", - // ctxt_pP->module_id, - // ctxt_pP->rnti, - // ctxt_pP->enb_flag, - // mbms_service_idP, - // mbms_session_idP); - if(h_rc != HASH_TABLE_OK) { - LOG_E(RLC, "RLC NOT FOUND enb id %u rnti %i enb flag %u service id %u, session id %u\n", - ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_service_idP, mbms_session_idP); - return; - } - - rlc_p = &rlc_union_p->rlc.um; - } else if ((sourceL2Id >0 ) && (destinationL2Id >0)) { - key = RLC_COLL_KEY_SOURCE_DEST_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, sourceL2Id, destinationL2Id, srb_flagP); - } else { - key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); - } - - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - //AssertFatal (h_rc == HASH_TABLE_OK, "RLC NOT FOUND enb id %u ue id %i enb flag %u rb id %u, srb flag %u", - // ctxt_pP->module_id, - // ctxt_pP->rnti, - // ctxt_pP->enb_flag, - // rb_idP, - // srb_flagP); - if(h_rc != HASH_TABLE_OK) { - LOG_E(RLC, "RLC NOT FOUND enb id %u ue id %i enb flag %u rb id %ld, srb flag %u\n", - ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); - return; - } - - rlc_p = &rlc_union_p->rlc.um; - //----------------------------------------------------------------------------- - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" CONFIG_REQ timer_reordering=%dms sn_field_length= RB %ld \n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), - (dl_rlc_pP && dl_rlc_pP->t_Reordering<31)?t_Reordering_tab[dl_rlc_pP->t_Reordering]:-1, - rb_idP); - rlc_um_init(ctxt_pP, rlc_p); - - if (rlc_um_fsm_notify_event (ctxt_pP, rlc_p, RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT)) { - rlc_um_set_debug_infos(ctxt_pP,rlc_p, srb_flagP, rb_idP, chan_idP); - - if (ul_rlc_pP != NULL) { - switch (ul_rlc_pP->sn_FieldLength) { - case LTE_SN_FieldLength_size5: - ul_sn_FieldLength = 5; - break; - - case LTE_SN_FieldLength_size10: - ul_sn_FieldLength = 10; - break; - - default: - LOG_E(RLC,PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %ld INVALID UL sn_FieldLength %ld, RLC NOT CONFIGURED\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), - rlc_p->rb_id, - ul_rlc_pP->sn_FieldLength); - return; - } - } - - if (dl_rlc_pP != NULL) { - switch (dl_rlc_pP->sn_FieldLength) { - case LTE_SN_FieldLength_size5: - dl_sn_FieldLength = 5; - break; - - case LTE_SN_FieldLength_size10: - dl_sn_FieldLength = 10; - break; - - default: - LOG_E(RLC,PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %ld INVALID DL sn_FieldLength %ld, RLC NOT CONFIGURED\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), - rlc_p->rb_id, - dl_rlc_pP->sn_FieldLength); - return; - } - - if (dl_rlc_pP->t_Reordering<32) { - t_Reordering = t_Reordering_tab[dl_rlc_pP->t_Reordering]; - } else { - LOG_E(RLC,PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %ld INVALID T_Reordering %ld, RLC NOT CONFIGURED\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), - rlc_p->rb_id, - dl_rlc_pP->t_Reordering); - return; - } - } - - if (ctxt_pP->enb_flag > 0) { - rlc_um_configure(ctxt_pP,rlc_p, - t_Reordering, - ul_sn_FieldLength, - dl_sn_FieldLength, - mbms_flagP); - } else { - rlc_um_configure(ctxt_pP,rlc_p, - t_Reordering, - dl_sn_FieldLength, - ul_sn_FieldLength, - mbms_flagP); - } - } -} -//----------------------------------------------------------------------------- -void -rlc_um_init ( - const protocol_ctxt_t *const ctxt_pP, - rlc_um_entity_t *const rlc_pP -) { - //AssertFatal(rlc_pP, "Bad RLC UM pointer (NULL)"); - if(rlc_pP == NULL) { - LOG_E(RLC, "Bad RLC UM pointer (NULL)\n"); - return; - } - - if (rlc_pP->initialized) { - LOG_D(RLC,PROTOCOL_RLC_UM_CTXT_FMT" [INIT] ALREADY DONE, DOING NOTHING\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); - } else { - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [INIT] STATE VARIABLES, BUFFERS, LISTS\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); - memset (rlc_pP, 0, sizeof (rlc_um_entity_t)); - // TX SIDE - list_init (&rlc_pP->pdus_to_mac_layer, NULL); - pthread_mutex_init(&rlc_pP->lock_input_sdus, NULL); - list_init (&rlc_pP->input_sdus, NULL); - rlc_pP->protocol_state = RLC_NULL_STATE; - //rlc_pP->vt_us = 0; - // RX SIDE - list_init (&rlc_pP->pdus_from_mac_layer, NULL); - //rlc_pP->vr_ur = 0; - //rlc_pP->vr_ux = 0; - //rlc_pP->vr_uh = 0; - //rlc_pP->output_sdu_size_to_write = 0; - //rlc_pP->output_sdu_in_construction = NULL; - rlc_pP->rx_sn_length = 10; - rlc_pP->rx_header_min_length_in_bytes = 2; - rlc_pP->tx_sn_length = 10; - rlc_pP->tx_header_min_length_in_bytes = 2; - pthread_mutex_init(&rlc_pP->lock_dar_buffer, NULL); - - if (rlc_pP->dar_buffer == NULL) { - rlc_pP->dar_buffer = calloc (1, 1024 * sizeof (void *)); - } - - rlc_pP->first_pdu = 1; - rlc_pP->initialized = true; - } -} -//----------------------------------------------------------------------------- -void -rlc_um_reset_state_variables ( - const protocol_ctxt_t *const ctxt_pP, - rlc_um_entity_t *const rlc_pP -) { - rlc_pP->buffer_occupancy = 0; - // TX SIDE - rlc_pP->vt_us = 0; - // RX SIDE - rlc_pP->vr_ur = 0; - rlc_pP->vr_ux = 0; - rlc_pP->vr_uh = 0; -} -//----------------------------------------------------------------------------- -void -rlc_um_cleanup ( - rlc_um_entity_t *const rlc_pP) { - int index; - // TX SIDE - list_free (&rlc_pP->pdus_to_mac_layer); - pthread_mutex_destroy(&rlc_pP->lock_input_sdus); - list_free (&rlc_pP->input_sdus); - // RX SIDE - list_free (&rlc_pP->pdus_from_mac_layer); - - if ((rlc_pP->output_sdu_in_construction)) { - free_mem_block (rlc_pP->output_sdu_in_construction, __func__); - rlc_pP->output_sdu_in_construction = NULL; - } - - if (rlc_pP->dar_buffer) { - for (index = 0; index < 1024; index++) { - if (rlc_pP->dar_buffer[index]) { - free_mem_block (rlc_pP->dar_buffer[index], __func__); - } - } - - free (rlc_pP->dar_buffer); - rlc_pP->dar_buffer = NULL; - } - - pthread_mutex_destroy(&rlc_pP->lock_dar_buffer); - memset(rlc_pP, 0, sizeof(rlc_um_entity_t)); -} - -//----------------------------------------------------------------------------- -void rlc_um_configure( - const protocol_ctxt_t *const ctxt_pP, - rlc_um_entity_t *const rlc_pP, - const uint32_t timer_reorderingP, - const uint32_t rx_sn_field_lengthP, - const uint32_t tx_sn_field_lengthP, - const uint32_t is_mXchP) { - if (rx_sn_field_lengthP == 10) { - rlc_pP->rx_sn_length = 10; - rlc_pP->rx_sn_modulo = RLC_UM_SN_10_BITS_MODULO; - rlc_pP->rx_um_window_size = RLC_UM_WINDOW_SIZE_SN_10_BITS; - rlc_pP->rx_header_min_length_in_bytes = 2; - } else if (rx_sn_field_lengthP == 5) { - rlc_pP->rx_sn_length = 5; - rlc_pP->rx_sn_modulo = RLC_UM_SN_5_BITS_MODULO; - rlc_pP->rx_um_window_size = RLC_UM_WINDOW_SIZE_SN_5_BITS; - rlc_pP->rx_header_min_length_in_bytes = 1; - } else if (rx_sn_field_lengthP != 0) { - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %ld INVALID RX SN LENGTH %d BITS NOT IMPLEMENTED YET, RLC NOT CONFIGURED\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->rb_id, - rx_sn_field_lengthP); - return; - } - - if (tx_sn_field_lengthP == 10) { - rlc_pP->tx_sn_length = 10; - rlc_pP->tx_sn_modulo = RLC_UM_SN_10_BITS_MODULO; - rlc_pP->tx_um_window_size = RLC_UM_WINDOW_SIZE_SN_10_BITS; - rlc_pP->tx_header_min_length_in_bytes = 2; - } else if (tx_sn_field_lengthP == 5) { - rlc_pP->tx_sn_length = 5; - rlc_pP->tx_sn_modulo = RLC_UM_SN_5_BITS_MODULO; - rlc_pP->tx_um_window_size = RLC_UM_WINDOW_SIZE_SN_5_BITS; - rlc_pP->tx_header_min_length_in_bytes = 1; - } else if (tx_sn_field_lengthP != 0) { - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %ld INVALID RX SN LENGTH %d BITS NOT IMPLEMENTED YET, RLC NOT CONFIGURED\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->rb_id, - tx_sn_field_lengthP); - return; - } - - if (is_mXchP > 0) { - rlc_pP->tx_um_window_size = 0; - rlc_pP->rx_um_window_size = 0; - } - - rlc_pP->is_mxch = is_mXchP; - rlc_pP->last_reassemblied_sn = rlc_pP->rx_sn_modulo - 1; - rlc_pP->last_reassemblied_missing_sn = rlc_pP->rx_sn_modulo - 1; - rlc_pP->reassembly_missing_sn_detected = 0; - // timers - rlc_um_init_timer_reordering(ctxt_pP,rlc_pP, timer_reorderingP); - rlc_pP->first_pdu = 1; - rlc_um_reset_state_variables (ctxt_pP,rlc_pP); -} -//----------------------------------------------------------------------------- -void rlc_um_set_debug_infos( - const protocol_ctxt_t *const ctxt_pP, - rlc_um_entity_t *const rlc_pP, - const srb_flag_t srb_flagP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP) { - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [SET DEBUG INFOS] rb_id %ld srb_flag %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - rb_idP, - srb_flagP); - rlc_pP->rb_id = rb_idP; - rlc_pP->channel_id = chan_idP; - - if (srb_flagP) { - rlc_pP->is_data_plane = 0; - } else { - rlc_pP->is_data_plane = 1; - } -} diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h deleted file mode 100644 index 45d7c4b3af196fb58e2546ee834fd9ea361d70de..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_um_control_primitives.h -* \brief This file defines the prototypes of the functions dealing with the control primitives and initialization. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_um_init_impl_ RLC UM Init Reference Implementation -* @ingroup _rlc_um_impl_ -* @{ -*/ -# ifndef __RLC_UM_CONTROL_PRIMITIVES_H__ -# define __RLC_UM_CONTROL_PRIMITIVES_H__ -//----------------------------------------------------------------------------- -# include "rlc_um_entity.h" -# include "mem_block.h" -# include "rlc_um_structs.h" -# include "rlc_um_constants.h" -# include "platform_types.h" -# include "LTE_DL-UM-RLC.h" -# include "LTE_UL-UM-RLC.h" -//----------------------------------------------------------------------------- - -typedef volatile struct { - uint32_t is_uplink_downlink; - uint32_t timer_reordering; - uint32_t sn_field_length; // 5 or 10 - uint32_t is_mXch; // boolean, true if configured for MTCH or MCCH -} rlc_um_info_t; - - -/*! \fn void config_req_rlc_um ( - * const protocol_ctxt_t* const ctxt_pP, - * const srb_flag_t srb_flagP, - * const rlc_um_info_t * const config_umP, - * const rb_id_t rb_idP) -* \brief Allocate memory for RLC UM instance, reset protocol variables, and set protocol parameters. After this configuration the RLC UM protocol instance will be in RLC_DATA_TRANSFER_READY_STATE state. -* \param[in] ctxt_pP Running context. -* \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). -* \param[in] config_umP Configuration parameters for RLC UM instance. -* \param[in] rb_idP Radio bearer identifier. -* \param[in] chan_idP Transport channel identifier. -*/ -void config_req_rlc_um ( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const rlc_um_info_t *const config_umP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP); - -/*! \fn void config_req_rlc_um_asn1 ( - * const protocol_ctxt_t* const ctxt_pP, - * const srb_flag_t srb_flagP, - * const MBMS_flag_t mbms_flagP, - * const mbms_session_id_t mbms_session_idP, - * const mbms_service_id_t mbms_service_idP, - * const UL_UM_RLC_t* const ul_rlc_pP, - * const DL_UM_RLC_t* const dl_rlc_pP, - * const rb_id_t rb_idP) -* \brief Allocate memory for RLC UM instance, reset protocol variables, and set protocol parameters. After this configuration the RLC UM protocol instance will be in RLC_DATA_TRANSFER_READY_STATE state. -* \param[in] ctxt_pP Running context. -* \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). -* \param[in] mbms_flagP Flag to indicate if this RLC is configured for MBMS. -* \param[in] mbms_session_idP MBMS session id. -* \param[in] mbms_service_idP MBMS service id. -* \param[in] ul_rlc_pP Configuration parameters for RLC UM UL instance. -* \param[in] dl_rlc_pP Configuration parameters for RLC UM DL instance. -* \param[in] rb_idP Radio bearer identifier. -* \param[in] chan_idP Transport channel identifier. -*/ -void config_req_rlc_um_asn1 ( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t mbms_flagP, - const mbms_session_id_t mbms_session_idP, - const mbms_service_id_t mbms_service_idP, - const LTE_UL_UM_RLC_t *const ul_rlc_pP, - const LTE_DL_UM_RLC_t *const dl_rlc_pP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP, - const uint32_t sourceL2Id, - const uint32_t destinationL2Id -); - -/*! \fn void rlc_um_init (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP) -* \brief Initialize a RLC UM protocol instance, initialize all variables, lists, allocate buffers for making this instance ready to be configured with protocol configuration parameters. After this initialization the RLC UM protocol instance will be in RLC_NULL_STATE state. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -*/ -void rlc_um_init ( - const protocol_ctxt_t *const ctxt_pP, - rlc_um_entity_t *const rlc_pP); - -/*! \fn void rlc_um_reset_state_variables (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP) -* \brief Reset protocol variables and state variables to initial values. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -*/ -void rlc_um_reset_state_variables ( - const protocol_ctxt_t *const ctxt_pP, - rlc_um_entity_t *const rlc_pP); - -/*! \fn void rlc_um_cleanup(rlc_um_entity_t * const rlc_pP) -* \brief Free all allocated memory (lists and buffers) previously allocated by this RLC UM instance. -* \param[in] rlc_pP RLC UM protocol instance pointer. -*/ -void rlc_um_cleanup( - rlc_um_entity_t *const rlc_pP); - -/*! \fn void rlc_um_configure( - * const protocol_ctxt_t* const ctxt_pP, - * rlc_um_entity_t * const rlc_pP, - * const uint32_t timer_reorderingP, - * const uint32_t rx_sn_field_lengthP, - * const uint32_t tx_sn_field_lengthP, - * const uint32_t is_mXchP) -* \brief Configure RLC UM protocol parameters. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] timer_reorderingP t-Reordering timer initialization value, units in frameP. -* \param[in] rx_sn_field_lengthP Length of the sequence number, 5 or 10 bits in reception. -* \param[in] tx_sn_field_lengthP Length of the sequence number, 5 or 10 bits in transmission. -* \param[in] is_mXchP Is the radio bearer for MCCH, MTCH. -*/ -void rlc_um_configure( - const protocol_ctxt_t *const ctxt_pP, - rlc_um_entity_t *const rlc_pP, - const uint32_t timer_reorderingP, - const uint32_t rx_sn_field_lengthP, - const uint32_t tx_sn_field_lengthP, - const uint32_t is_mXchP); - -/*! \fn void rlc_um_set_debug_infos( -* const protocol_ctxt_t* const ctxt_pP, -* rlc_um_entity_t * const rlc_pP, -* const srb_flag_t srb_flagP, -* const rb_id_t rb_idP) -* \brief Set debug informations for a RLC UM protocol instance, these informations are only for trace purpose. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0). -* \param[in] rb_idP Radio bearer identifier. -* \param[in] chan_idP Transport channel identifier. -*/ -void rlc_um_set_debug_infos( - const protocol_ctxt_t *const ctxt_pP, - rlc_um_entity_t *const rlc_pP, - const srb_flag_t srb_flagP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP); -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c deleted file mode 100644 index 6d2380d4ffe840ac52139375c2eeb7fd6b9636b3..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c +++ /dev/null @@ -1,1220 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_UM_MODULE 1 -#define RLC_UM_DAR_C 1 -#include "platform_types.h" -#include "assertions.h" -//----------------------------------------------------------------------------- -#include "rlc.h" -#include "rlc_um.h" -#include "rlc_primitives.h" -#include "mac_primitives.h" -#include "list.h" -#include "common/utils/LOG/log.h" -#include "common/utils/LOG/vcd_signal_dumper.h" -//----------------------------------------------------------------------------- -signed int rlc_um_get_pdu_infos( - const protocol_ctxt_t* const ctxt_pP, - const rlc_um_entity_t* const rlc_pP, - rlc_um_pdu_sn_10_t * const header_pP, - const sdu_size_t total_sizeP, - rlc_um_pdu_info_t * const pdu_info_pP, - const uint8_t sn_lengthP) -{ - sdu_size_t sum_li = 0; - memset(pdu_info_pP, 0, sizeof (rlc_um_pdu_info_t)); - - pdu_info_pP->num_li = 0; - - //AssertFatal( total_sizeP > 0 , "RLC UM PDU LENGTH %d", total_sizeP); - if(total_sizeP <= 0) { - LOG_E(RLC, "RLC UM PDU LENGTH %d\n", total_sizeP); - return -1; - } - - if (sn_lengthP == 10) { - pdu_info_pP->fi = (header_pP->b1 >> 3) & 0x03; - pdu_info_pP->e = (header_pP->b1 >> 2) & 0x01; - pdu_info_pP->sn = header_pP->b2 + (((uint16_t)(header_pP->b1 & 0x03)) << 8); - pdu_info_pP->header_size = 2; - pdu_info_pP->payload = &header_pP->data[0]; - } else if (sn_lengthP == 5) { - pdu_info_pP->fi = (header_pP->b1 >> 6) & 0x03; - pdu_info_pP->e = (header_pP->b1 >> 5) & 0x01; - pdu_info_pP->sn = header_pP->b1 & 0x1F; - pdu_info_pP->header_size = 1; - pdu_info_pP->payload = &header_pP->b2; - } else { - //AssertFatal( sn_lengthP == 5 || sn_lengthP == 10, "RLC UM SN LENGTH %d", sn_lengthP); - if(!(sn_lengthP == 5 || sn_lengthP == 10)) { - LOG_E(RLC, "RLC UM SN LENGTH %d\n", sn_lengthP); - return -1; - } - } - - - if (pdu_info_pP->e) { - rlc_am_e_li_t *e_li_p; - unsigned int li_length_in_bytes = 1; - unsigned int li_to_read = 1; - - e_li_p = (rlc_am_e_li_t*)(pdu_info_pP->payload); - - while (li_to_read) { - li_length_in_bytes = li_length_in_bytes ^ 3; - - if (li_length_in_bytes == 2) { - //AssertFatal( total_sizeP >= ((uint64_t)(&e_li_p->b2) - (uint64_t)header_pP), - // "DECODING PDU TOO FAR PDU size %d", total_sizeP); - if(total_sizeP < ((uint64_t)(&e_li_p->b2) - (uint64_t)header_pP)) { - LOG_E(RLC, "DECODING PDU TOO FAR PDU size %d\n", total_sizeP); - return -1; - } - pdu_info_pP->li_list[pdu_info_pP->num_li] = ((uint16_t)(e_li_p->b1 << 4)) & 0x07F0; - pdu_info_pP->li_list[pdu_info_pP->num_li] |= (((uint8_t)(e_li_p->b2 >> 4)) & 0x000F); - li_to_read = e_li_p->b1 & 0x80; - pdu_info_pP->header_size += 2; - } else { - //AssertFatal( total_sizeP >= ((uint64_t)(&e_li_p->b3) - (uint64_t)header_pP), - // "DECODING PDU TOO FAR PDU size %d", total_sizeP); - if(total_sizeP < ((uint64_t)(&e_li_p->b3) - (uint64_t)header_pP)) { - LOG_E(RLC, "DECODING PDU TOO FAR PDU size %d\n", total_sizeP); - return -1; - } - pdu_info_pP->li_list[pdu_info_pP->num_li] = ((uint16_t)(e_li_p->b2 << 8)) & 0x0700; - pdu_info_pP->li_list[pdu_info_pP->num_li] |= e_li_p->b3; - li_to_read = e_li_p->b2 & 0x08; - e_li_p++; - pdu_info_pP->header_size += 1; - } - - //AssertFatal( pdu_info_pP->num_li <= RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU, - // PROTOCOL_RLC_UM_CTXT_FMT"[GET PDU INFO] SN %04d TOO MANY LIs ", - // PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - // pdu_info_pP->sn); - if(pdu_info_pP->num_li >= RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU) { - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[GET PDU INFO] SN %04d TOO MANY LIs \n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - pdu_info_pP->sn); - return -1; - } - - sum_li += pdu_info_pP->li_list[pdu_info_pP->num_li]; - pdu_info_pP->num_li = pdu_info_pP->num_li + 1; - - if (pdu_info_pP->num_li > RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU) { - return -2; - } - } - - if (li_length_in_bytes == 2) { - pdu_info_pP->payload = &e_li_p->b3; - } else { - pdu_info_pP->payload = &e_li_p->b1; - } - } - - pdu_info_pP->payload_size = total_sizeP - pdu_info_pP->header_size; - - if (pdu_info_pP->payload_size > sum_li) { - pdu_info_pP->hidden_size = pdu_info_pP->payload_size - sum_li; - } - - return 0; -} -//----------------------------------------------------------------------------- -int rlc_um_read_length_indicators(unsigned char**data_ppP, rlc_um_e_li_t* e_liP, unsigned int* li_array_pP, unsigned int *num_li_pP, sdu_size_t *data_size_pP) -{ - int continue_loop = 1; - unsigned int e1 = 0; - unsigned int li1 = 0; - unsigned int e2 = 0; - unsigned int li2 = 0; - *num_li_pP = 0; - - while ((continue_loop)) { - //msg("[RLC_UM] e_liP->b1 = %02X\n", e_liP->b1); - //msg("[RLC_UM] e_liP->b2 = %02X\n", e_liP->b2); - e1 = ((unsigned int)e_liP->b1 & 0x00000080) >> 7; - li1 = (((unsigned int)e_liP->b1 & 0x0000007F) << 4) + (((unsigned int)e_liP->b2 & 0x000000F0) >> 4); - li_array_pP[*num_li_pP] = li1; - *data_size_pP = *data_size_pP - li1 - 2; - *num_li_pP = *num_li_pP +1; - - if ((e1)) { - e2 = ((unsigned int)e_liP->b2 & 0x00000008) >> 3; - li2 = (((unsigned int)e_liP->b2 & 0x00000007) << 8) + ((unsigned int)e_liP->b3 & 0x000000FF); - li_array_pP[*num_li_pP] = li2; - *data_size_pP = *data_size_pP - li2 - 1; - *num_li_pP = *num_li_pP +1; - - if (!(*data_size_pP >= 0)) LOG_E(RLC, "Invalid data_size=%d! (pdu_size=%d loop=%d e1=%d e2=%d li2=%d e_liP=%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x)\n", - *data_size_pP, *data_size_pP, continue_loop, e1, e2, li2, - (e_liP-(continue_loop-1)+0)->b1, - (e_liP-(continue_loop-1)+0)->b2, - (e_liP-(continue_loop-1)+0)->b3, - (e_liP-(continue_loop-1)+1)->b1, - (e_liP-(continue_loop-1)+1)->b2, - (e_liP-(continue_loop-1)+1)->b3, - (e_liP-(continue_loop-1)+2)->b1, - (e_liP-(continue_loop-1)+2)->b2, - (e_liP-(continue_loop-1)+2)->b3); - // AssertFatal(*data_size_pP >= 0, "Invalid data_size!"); - - if (e2 == 0) { - continue_loop = 0; - } else { - e_liP++; - continue_loop++; - } - } else { - if (!(*data_size_pP >= 0)) LOG_E(RLC, "Invalid data_size=%d! (pdu_size=%d loop=%d e1=%d li1=%d e_liP=%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x)\n", - *data_size_pP, *data_size_pP, continue_loop, e1, li1, - (e_liP-(continue_loop-1)+0)->b1, - (e_liP-(continue_loop-1)+0)->b2, - (e_liP-(continue_loop-1)+0)->b3, - (e_liP-(continue_loop-1)+1)->b1, - (e_liP-(continue_loop-1)+1)->b2, - (e_liP-(continue_loop-1)+1)->b3, - (e_liP-(continue_loop-1)+2)->b1, - (e_liP-(continue_loop-1)+2)->b2, - (e_liP-(continue_loop-1)+2)->b3); - continue_loop = 0; - // AssertFatal(*data_size_pP >= 0, "Invalid data_size!"); - } - - if (*num_li_pP > RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU) { - return -1; - } - } - - *data_ppP = *data_ppP + (((*num_li_pP*3) +1) >> 1); - if (*data_size_pP > 0) { - return 0; - } else if (*data_size_pP == 0) { - LOG_W(RLC, "Last RLC SDU size is zero!\n"); - return -1; - } else { - LOG_W(RLC, "Last RLC SDU size is negative %d!\n", *data_size_pP); - return -1; - } -} -//----------------------------------------------------------------------------- -void -rlc_um_try_reassembly( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t * rlc_pP, - rlc_sn_t start_snP, - rlc_sn_t end_snP) -{ - mem_block_t *pdu_mem_p = NULL; - struct mac_tb_ind *tb_ind_p = NULL; - rlc_um_e_li_t *e_li_p = NULL; - unsigned char *data_p = NULL; - int e = 0; - int fi = 0; - sdu_size_t size = 0; - rlc_sn_t sn = 0; - unsigned int continue_reassembly = 0; - unsigned int num_li = 0; - unsigned int li_array[RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU]; - int i = 0; - int reassembly_start_index = 0; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_TRY_REASSEMBLY,VCD_FUNCTION_IN); - - if (end_snP < 0) { - end_snP = end_snP + rlc_pP->rx_sn_modulo; - } - - if (start_snP < 0) { - start_snP = start_snP + rlc_pP->rx_sn_modulo; - } - -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY FROM PDU SN=%03d+1 TO PDU SN=%03d SN Length = %d bits (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - rlc_pP->last_reassemblied_sn, - end_snP, - rlc_pP->rx_sn_length, - __FILE__, - __LINE__); -#endif - - // nothing to be reassemblied - if (start_snP == end_snP) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_TRY_REASSEMBLY,VCD_FUNCTION_OUT); - return; - } - - continue_reassembly = 1; - //sn = (rlc_pP->last_reassemblied_sn + 1) % rlc_pP->rx_sn_modulo; - sn = start_snP; - - //check_mem_area(); - - while (continue_reassembly) { - if ((pdu_mem_p = rlc_pP->dar_buffer[sn])) { - - if ((rlc_pP->last_reassemblied_sn+1)%rlc_pP->rx_sn_modulo != sn) { -#if TRACE_RLC_UM_DAR - LOG_W(RLC, - PROTOCOL_RLC_UM_CTXT_FMT" FINDING a HOLE in RLC UM SN: CLEARING OUTPUT SDU BECAUSE NEW SN (%03d) TO REASSEMBLY NOT CONTIGUOUS WITH LAST REASSEMBLIED SN (%03d) (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn, - rlc_pP->last_reassemblied_sn, - __FILE__, - __LINE__); -#endif - rlc_um_clear_rx_sdu(ctxt_pP, rlc_pP); - } - - rlc_pP->last_reassemblied_sn = sn; - tb_ind_p = (struct mac_tb_ind *)(pdu_mem_p->data); - - if (rlc_pP->rx_sn_length == 10) { -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY 10 PDU SN=%03d\n (%s:%u)", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn, - __FILE__, - __LINE__); -#endif - e = (((rlc_um_pdu_sn_10_t*)(tb_ind_p->data_ptr))->b1 & 0x04) >> 2; - fi = (((rlc_um_pdu_sn_10_t*)(tb_ind_p->data_ptr))->b1 & 0x18) >> 3; - e_li_p = (rlc_um_e_li_t*)((rlc_um_pdu_sn_10_t*)(tb_ind_p->data_ptr))->data; - size = tb_ind_p->size - 2; - data_p = &tb_ind_p->data_ptr[2]; - } else { -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY 5 PDU SN=%03d Byte 0=%02X (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn, - ((rlc_um_pdu_sn_5_t*)(tb_ind_p->data_ptr))->b1, - __FILE__, - __LINE__); -#endif - e = (((rlc_um_pdu_sn_5_t*)(tb_ind_p->data_ptr))->b1 & 0x00000020) >> 5; - fi = (((rlc_um_pdu_sn_5_t*)(tb_ind_p->data_ptr))->b1 & 0x000000C0) >> 6; - e_li_p = (rlc_um_e_li_t*)((rlc_um_pdu_sn_5_t*)(tb_ind_p->data_ptr))->data; - size = tb_ind_p->size - 1; - data_p = &tb_ind_p->data_ptr[1]; -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" e=%01X fi=%01X\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - e, - fi, - __FILE__, - __LINE__); -#endif - } - //AssertFatal(size >= 0, "invalid size!"); - //AssertFatal((e==0) || (e==1), "invalid e!"); - //AssertFatal((fi >= 0) && (fi <= 3), "invalid fi!"); - if((size < 0) || ((e!=0) && (e!=1)) || ((fi < 0) || (fi > 3))){ - LOG_E(RLC, "invalid size %d, e %d, fi %d\n", size, e, fi); - sn = (sn + 1) % rlc_pP->rx_sn_modulo; - if ((sn == rlc_pP->vr_uh) || (sn == end_snP)) { - continue_reassembly = 0; - } - continue; - } - - if (e == RLC_E_FIXED_PART_DATA_FIELD_FOLLOW) { - switch (fi) { - case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU NO E_LI FI=11 (00) (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - __FILE__, - __LINE__); -#endif - // one complete SDU - //LGrlc_um_send_sdu(rlc_pP,ctxt_pP->frame,ctxt_pP->enb_flag); // may be not necessary - rlc_um_clear_rx_sdu(ctxt_pP, rlc_pP); - rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, size); - rlc_um_send_sdu(ctxt_pP, rlc_pP); - rlc_pP->reassembly_missing_sn_detected = 0; - - break; - - case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU NO E_LI FI=10 (01) (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - __FILE__, - __LINE__); -#endif - // one beginning segment of SDU in PDU - //LG rlc_um_send_sdu(rlc_pP,ctxt_pP->frame,ctxt_pP->enb_flag); // may be not necessary - rlc_um_clear_rx_sdu(ctxt_pP, rlc_pP); - rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, size); - rlc_pP->reassembly_missing_sn_detected = 0; - break; - - case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU NO E_LI FI=01 (10) (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - __FILE__, - __LINE__); -#endif - - // one last segment of SDU - if (rlc_pP->reassembly_missing_sn_detected == 0) { - rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, size); - rlc_um_send_sdu(ctxt_pP, rlc_pP); - } else { - //clear sdu already done - rlc_pP->stat_rx_data_pdu_dropped += 1; - rlc_pP->stat_rx_data_bytes_dropped += tb_ind_p->size; - } - - rlc_pP->reassembly_missing_sn_detected = 0; - break; - - case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU NO E_LI FI=00 (11) (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - __FILE__, - __LINE__); -#endif - - if (rlc_pP->reassembly_missing_sn_detected == 0) { - // one whole segment of SDU in PDU - rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, size); - } else { -#if TRACE_RLC_UM_DAR - LOG_W(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU NO E_LI FI=00 (11) MISSING SN DETECTED (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - __FILE__, - __LINE__); -#endif - //LOG_D(RLC, "[MSC_NBOX][FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u][Missing SN detected][RLC_UM][MOD %u/%u][RB %u]\n", - // ctxt_pP->frame, rlc_pP->module_id,rlc_pP->rb_id, rlc_pP->module_id,rlc_pP->rb_id); - rlc_pP->reassembly_missing_sn_detected = 1; // not necessary but for readability of the code - rlc_pP->stat_rx_data_pdu_dropped += 1; - rlc_pP->stat_rx_data_bytes_dropped += tb_ind_p->size; -#if RLC_STOP_ON_LOST_PDU - AssertFatal( rlc_pP->reassembly_missing_sn_detected == 1, - PROTOCOL_RLC_UM_CTXT_FMT" MISSING PDU DETECTED (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - __FILE__, - __LINE__); -#endif - } - - break; - - default: - //AssertFatal( 0 , PROTOCOL_RLC_UM_CTXT_FMT" fi=%d! TRY REASSEMBLY SHOULD NOT GO HERE (%s:%u)\n", - // PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - // fi, - // __FILE__, - // __LINE__); - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" fi=%d! TRY REASSEMBLY SHOULD NOT GO HERE (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), fi, __FILE__, __LINE__); - - } - } else { - if (rlc_um_read_length_indicators(&data_p, e_li_p, li_array, &num_li, &size ) >= 0) { - switch (fi) { - case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU FI=11 (00) Li=", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - - for (i=0; i < num_li; i++) { - LOG_D(RLC, "%d ",li_array[i]); - } - - LOG_D(RLC, " remaining size %d\n",size); -#endif - // N complete SDUs - //LGrlc_um_send_sdu(rlc_pP,ctxt_pP->frame,ctxt_pP->enb_flag); - rlc_um_clear_rx_sdu(ctxt_pP, rlc_pP); - - for (i = 0; i < num_li; i++) { - rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, li_array[i]); - rlc_um_send_sdu(ctxt_pP, rlc_pP); - data_p = &data_p[li_array[i]]; - } - - if (size > 0) { // normally should always be > 0 but just for help debug - // data_p is already ok, done by last loop above - rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, size); - rlc_um_send_sdu(ctxt_pP, rlc_pP); - } - - rlc_pP->reassembly_missing_sn_detected = 0; - break; - - case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU FI=10 (01) Li=", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - - for (i=0; i < num_li; i++) { - LOG_D(RLC, "%d ",li_array[i]); - } - - LOG_D(RLC, " remaining size %d\n",size); -#endif - // N complete SDUs + one segment of SDU in PDU - //LG rlc_um_send_sdu(rlc_pP,ctxt_pP->frame,ctxt_pP->enb_flag); - rlc_um_clear_rx_sdu(ctxt_pP, rlc_pP); - - for (i = 0; i < num_li; i++) { - rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, li_array[i]); - rlc_um_send_sdu(ctxt_pP, rlc_pP); - data_p = &data_p[li_array[i]]; - } - - if (size > 0) { // normally should always be > 0 but just for help debug - // data_p is already ok, done by last loop above - rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, size); - } - - rlc_pP->reassembly_missing_sn_detected = 0; - break; - - case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU FI=01 (10) Li=", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - - for (i=0; i < num_li; i++) { - LOG_D(RLC, "%d ",li_array[i]); - } - - LOG_D(RLC, " remaining size %d\n",size); -#endif - - if (rlc_pP->reassembly_missing_sn_detected) { - reassembly_start_index = 1; - data_p = &data_p[li_array[0]]; - //rlc_pP->stat_rx_data_pdu_dropped += 1; - rlc_pP->stat_rx_data_bytes_dropped += li_array[0]; - } else { - reassembly_start_index = 0; - } - - // one last segment of SDU + N complete SDUs in PDU - for (i = reassembly_start_index; i < num_li; i++) { - rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, li_array[i]); - rlc_um_send_sdu(ctxt_pP, rlc_pP); - data_p = &data_p[li_array[i]]; - } - - if (size > 0) { // normally should always be > 0 but just for help debug - // data_p is already ok, done by last loop above - rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, size); - rlc_um_send_sdu(ctxt_pP, rlc_pP); - } - - rlc_pP->reassembly_missing_sn_detected = 0; - break; - - case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRY REASSEMBLY PDU FI=00 (11) Li=", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - - for (i=0; i < num_li; i++) { - LOG_D(RLC, "%d ",li_array[i]); - } - - LOG_D(RLC, " remaining size %d\n",size); -#endif - - if (rlc_pP->reassembly_missing_sn_detected) { -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" DISCARD FIRST LI %d (%s:%u)", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - li_array[0], - __FILE__, - __LINE__); -#endif - reassembly_start_index = 1; - data_p = &data_p[li_array[0]]; - //rlc_pP->stat_rx_data_pdu_dropped += 1; - rlc_pP->stat_rx_data_bytes_dropped += li_array[0]; - } else { - reassembly_start_index = 0; - } - - for (i = reassembly_start_index; i < num_li; i++) { - rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, li_array[i]); - rlc_um_send_sdu(ctxt_pP, rlc_pP); - data_p = &data_p[li_array[i]]; - } - - if (size > 0) { // normally should always be > 0 but just for help debug - // data_p is already ok, done by last loop above - rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, size); - } else { - //AssertFatal( 0 !=0, PROTOCOL_RLC_UM_CTXT_FMT" size=%d! SHOULD NOT GO HERE (%s:%u)\n", - // PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - // size, - // __FILE__, - // __LINE__); - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" size=%d! SHOULD NOT GO HERE (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), size, __FILE__, __LINE__); - - //rlc_pP->stat_rx_data_pdu_dropped += 1; - rlc_pP->stat_rx_data_bytes_dropped += size; - } - - rlc_pP->reassembly_missing_sn_detected = 0; - break; - - default: -#if TRACE_RLC_UM_DAR - LOG_W(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Missing SN detected (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - __FILE__, - __LINE__); -#endif - rlc_pP->stat_rx_data_pdu_dropped += 1; - rlc_pP->stat_rx_data_bytes_dropped += tb_ind_p->size; - - rlc_pP->reassembly_missing_sn_detected = 1; -#if RLC_STOP_ON_LOST_PDU - AssertFatal( rlc_pP->reassembly_missing_sn_detected == 1, - PROTOCOL_RLC_UM_CTXT_FMT" MISSING PDU DETECTED (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - __FILE__, - __LINE__); -#endif - } - } else { - rlc_pP->stat_rx_data_pdu_dropped += 1; - rlc_pP->stat_rx_data_bytes_dropped += tb_ind_p->size; - rlc_pP->reassembly_missing_sn_detected = 1; - - LOG_W(RLC, "[SN %d] Bad RLC header! Discard this RLC PDU (size=%d)\n", sn, size); - } - } - -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" REMOVE PDU FROM DAR BUFFER SN=%03d (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn, - __FILE__, - __LINE__); -#endif - free_mem_block(rlc_pP->dar_buffer[sn], __func__); - rlc_pP->dar_buffer[sn] = NULL; - } else { - rlc_pP->last_reassemblied_missing_sn = sn; -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Missing SN %04d detected, clearing RX SDU (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn, - __FILE__, - __LINE__); -#endif - rlc_pP->reassembly_missing_sn_detected = 1; - rlc_um_clear_rx_sdu(ctxt_pP, rlc_pP); -#if RLC_STOP_ON_LOST_PDU - AssertFatal( rlc_pP->reassembly_missing_sn_detected == 1, - PROTOCOL_RLC_UM_CTXT_FMT" MISSING PDU DETECTED (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - __FILE__, - __LINE__); -#endif - } - - sn = (sn + 1) % rlc_pP->rx_sn_modulo; - - if ((sn == rlc_pP->vr_uh) || (sn == end_snP)) { - continue_reassembly = 0; - } - } - -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TRIED REASSEMBLY VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - rlc_pP->vr_ur, - rlc_pP->vr_ux, - rlc_pP->vr_uh, - __FILE__, - __LINE__); -#endif - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_TRY_REASSEMBLY,VCD_FUNCTION_OUT); -} -//----------------------------------------------------------------------------- -void -rlc_um_stop_and_reset_timer_reordering( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t * rlc_pP) -{ -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [T-REORDERING] STOPPED AND RESET\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); -#endif - rlc_pP->t_reordering.running = 0; - rlc_pP->t_reordering.ms_time_out = 0; - rlc_pP->t_reordering.ms_start = 0; - rlc_pP->t_reordering.timed_out = 0; -} -//----------------------------------------------------------------------------- -void -rlc_um_start_timer_reordering( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t * rlc_pP) -{ - rlc_pP->t_reordering.timed_out = 0; - - if (rlc_pP->t_reordering.ms_duration > 0) { - rlc_pP->t_reordering.running = 1; - rlc_pP->t_reordering.ms_time_out = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) + rlc_pP->t_reordering.ms_duration; - rlc_pP->t_reordering.ms_start = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" [T-REORDERING] STARTED (TIME-OUT = FRAME %05u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - rlc_pP->t_reordering.ms_time_out); -#endif - } else { - LOG_T(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[T-REORDERING] NOT STARTED, CAUSE CONFIGURED 0 ms\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); - } -} -//----------------------------------------------------------------------------- -void -rlc_um_init_timer_reordering( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t * const rlc_pP, - const uint32_t ms_durationP) -{ - rlc_pP->t_reordering.running = 0; - rlc_pP->t_reordering.ms_time_out = 0; - rlc_pP->t_reordering.ms_start = 0; - rlc_pP->t_reordering.ms_duration = ms_durationP; - rlc_pP->t_reordering.timed_out = 0; -} -//----------------------------------------------------------------------------- -void rlc_um_check_timer_dar_time_out( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t * const rlc_pP) -{ - signed int in_window; - rlc_usn_t old_vr_ur; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_CHECK_TIMER_DAR_TIME_OUT,VCD_FUNCTION_IN); - - if ((rlc_pP->t_reordering.running)) { - if ( - // CASE 1: start time out - // +-----------+------------------+----------+ - // | |******************| | - // +-----------+------------------+----------+ - //FRAME # 0 FRAME MAX - ((rlc_pP->t_reordering.ms_start < rlc_pP->t_reordering.ms_time_out) && - ((PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_reordering.ms_time_out) || - (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_reordering.ms_start))) || - // CASE 2: time out start - // +-----------+------------------+----------+ - // |***********| |**********| - // +-----------+------------------+----------+ - //FRAME # 0 FRAME MAX VALUE - ((rlc_pP->t_reordering.ms_start > rlc_pP->t_reordering.ms_time_out) && - (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) < rlc_pP->t_reordering.ms_start) && - (PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP) >= rlc_pP->t_reordering.ms_time_out)) - ) { - - //if ((uint32_t)((uint32_t)rlc_pP->timer_reordering + (uint32_t)rlc_pP->timer_reordering_init) <= ctxt_pP->frame) { - // 5.1.2.2.4 Actions when t-Reordering expires - // When t-Reordering expires, the receiving UM RLC entity shall: - // -update VR(UR) to the SN of the first UMD PDU with SN >= VR(UX) that has not been received; - // -reassemble RLC SDUs from any UMD PDUs with SN < updated VR(UR), remove RLC headers when doing so and deliver the reassembled RLC SDUs to upper layer in ascending order of the RLC SN if not delivered before; - // -if VR(UH) > VR(UR): - // -start t-Reordering; - // -set VR(UX) to VR(UH). - rlc_pP->stat_timer_reordering_timed_out += 1; -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT"*****************************************************\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT"* T I M E - O U T *\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT"*****************************************************\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TIMER t-Reordering expiration\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" timer_reordering=%d frame=%d expire ms %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - rlc_pP->t_reordering.ms_duration, - ctxt_pP->frame, - rlc_pP->t_reordering.ms_time_out); - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" set VR(UR)=%03d to", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - rlc_pP->vr_ur); -#endif - - if (pthread_mutex_trylock(&rlc_pP->lock_dar_buffer) == 0) { - old_vr_ur = rlc_pP->vr_ur; - - rlc_pP->vr_ur = rlc_pP->vr_ux; - - while (rlc_um_get_pdu_from_dar_buffer(ctxt_pP, rlc_pP, rlc_pP->vr_ur)) { - rlc_pP->vr_ur = (rlc_pP->vr_ur+1)%rlc_pP->rx_sn_modulo; - } - -#if TRACE_RLC_UM_DAR - LOG_D(RLC, " %d", rlc_pP->vr_ur); - LOG_D(RLC, "\n"); -#endif - rlc_um_try_reassembly(ctxt_pP, rlc_pP ,old_vr_ur, rlc_pP->vr_ur); - - in_window = rlc_um_in_window(ctxt_pP, rlc_pP, rlc_pP->vr_ur, rlc_pP->vr_uh, rlc_pP->vr_uh); - - if (in_window == 2) { - rlc_um_start_timer_reordering(ctxt_pP, rlc_pP); - rlc_pP->vr_ux = rlc_pP->vr_uh; -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" restarting t-Reordering set VR(UX) to %d (VR(UH)>VR(UR))\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - rlc_pP->vr_ux); -#endif - } else { -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" STOP t-Reordering VR(UX) = %03d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - rlc_pP->vr_ux); -#endif - rlc_um_stop_and_reset_timer_reordering(ctxt_pP, rlc_pP); - } - - RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_dar_buffer); - } - } - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_CHECK_TIMER_DAR_TIME_OUT,VCD_FUNCTION_OUT); -} -//----------------------------------------------------------------------------- -mem_block_t* -rlc_um_remove_pdu_from_dar_buffer( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t * const rlc_pP, - rlc_usn_t snP) -{ - mem_block_t * pdu_p = rlc_pP->dar_buffer[snP]; -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" REMOVE PDU FROM DAR BUFFER SN=%03d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - snP); -#endif - rlc_pP->dar_buffer[snP] = NULL; - return pdu_p; -} -//----------------------------------------------------------------------------- -mem_block_t* -rlc_um_get_pdu_from_dar_buffer(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, rlc_usn_t snP) -{ - return rlc_pP->dar_buffer[snP]; -} -//----------------------------------------------------------------------------- -void -rlc_um_store_pdu_in_dar_buffer( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t * const rlc_pP, - mem_block_t *pdu_pP, - rlc_usn_t snP) -{ -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" STORE PDU IN DAR BUFFER SN=%03d VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - snP, - rlc_pP->vr_ur, - rlc_pP->vr_ux, - rlc_pP->vr_uh); -#endif - rlc_pP->dar_buffer[snP] = pdu_pP; -} -//----------------------------------------------------------------------------- -// returns -2 if lower_bound > sn -// returns -1 if higher_bound < sn -// returns 0 if lower_bound < sn < higher_bound -// returns 1 if lower_bound == sn -// returns 2 if higher_bound == sn -// returns 3 if higher_bound == sn == lower_bound -signed int -rlc_um_in_window( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t * const rlc_pP, - rlc_sn_t lower_boundP, - rlc_sn_t snP, - rlc_sn_t higher_boundP) -{ - rlc_sn_t modulus = (rlc_sn_t)rlc_pP->vr_uh - rlc_pP->rx_um_window_size; -#if TRACE_RLC_UM_RX - rlc_sn_t lower_bound = lower_boundP; - rlc_sn_t higher_bound = higher_boundP; - rlc_sn_t sn = snP; -#endif - lower_boundP = (lower_boundP - modulus) % rlc_pP->rx_sn_modulo; - higher_boundP = (higher_boundP - modulus) % rlc_pP->rx_sn_modulo; - snP = (snP - modulus) % rlc_pP->rx_sn_modulo; - - if ( lower_boundP > snP) { -#if TRACE_RLC_UM_RX - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d not in WINDOW[%03d:%03d] (SN<LOWER BOUND)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn, - lower_bound, - higher_bound); -#endif - return -2; - } - - if ( higher_boundP < snP) { -#if TRACE_RLC_UM_RX - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d not in WINDOW[%03d:%03d] (SN>HIGHER BOUND) <=> %d not in WINDOW[%03d:%03d]\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn, - lower_bound, - higher_bound, - snP, - lower_boundP, - higher_boundP); -#endif - return -1; - } - - if ( lower_boundP == snP) { - if ( higher_boundP == snP) { -#if TRACE_RLC_UM_RX - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d in WINDOW[%03d:%03d] (SN=HIGHER BOUND=LOWER BOUND)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn, - lower_bound, - higher_bound); -#endif - return 3; - } - -#if TRACE_RLC_UM_RX - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d in WINDOW[%03d:%03d] (SN=LOWER BOUND)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn, - lower_bound, - higher_bound); -#endif - return 1; - } - - if ( higher_boundP == snP) { -#if TRACE_RLC_UM_RX - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d in WINDOW[%03d:%03d] (SN=HIGHER BOUND)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn, - lower_bound, - higher_bound); -#endif - return 2; - } - - return 0; - -} -//----------------------------------------------------------------------------- -signed int -rlc_um_in_reordering_window( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t * const rlc_pP, - const rlc_sn_t snP) -{ - rlc_sn_t modulus = (signed int)rlc_pP->vr_uh - rlc_pP->rx_um_window_size; - rlc_sn_t sn_mod = (snP - modulus) % rlc_pP->rx_sn_modulo; - - if ( 0 <= sn_mod) { - if (sn_mod < rlc_pP->rx_um_window_size) { -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d IN REORDERING WINDOW[%03d:%03d[ SN %d IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn_mod, - 0, - rlc_pP->rx_um_window_size, - snP, - (signed int)rlc_pP->vr_uh - rlc_pP->rx_um_window_size, - rlc_pP->vr_uh, - rlc_pP->vr_ur, - rlc_pP->vr_uh); -#endif - return 0; - } - } - -#if TRACE_RLC_UM_DAR - - if (modulus < 0) { - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d NOT IN REORDERING WINDOW[%03d:%03d[ SN %d NOT IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn_mod, - modulus + 1024, - rlc_pP->rx_um_window_size, - snP, - modulus + 1024 , - rlc_pP->vr_uh, - rlc_pP->vr_ur, - rlc_pP->vr_uh); - } else { - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" %d NOT IN REORDERING WINDOW[%03d:%03d[ SN %d NOT IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn_mod, - modulus, - rlc_pP->rx_um_window_size, - snP, - modulus , - rlc_pP->vr_uh, - rlc_pP->vr_ur, - rlc_pP->vr_uh); - } - -#endif - return -1; -} -//----------------------------------------------------------------------------- -void -rlc_um_receive_process_dar ( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t * const rlc_pP, - mem_block_t * pdu_mem_pP, - rlc_um_pdu_sn_10_t * const pdu_pP, - const sdu_size_t tb_sizeP) -{ - // 36.322v9.3.0 section 5.1.2.2.1: - // The receiving UM RLC entity shall maintain a reordering window according to state variable VR(UH) as follows: - // -a SN falls within the reordering window if (VR(UH) – UM_Window_Size) <= SN < VR(UH); - // -a SN falls outside of the reordering window otherwise. - // When receiving an UMD PDU from lower layer, the receiving UM RLC entity shall: - // -either discard the received UMD PDU or place it in the reception buffer (see sub clause 5.1.2.2.2); - // -if the received UMD PDU was placed in the reception buffer: - // -update state variables, reassemble and deliver RLC SDUs to upper layer and start/stop t-Reordering as needed (see sub clause 5.1.2.2.3); - // When t-Reordering expires, the receiving UM RLC entity shall: - // - update state variables, reassemble and deliver RLC SDUs to upper layer and start t-Reordering as needed (see sub clause 5.1.2.2.4). - - - - // When an UMD PDU with SN = x is received from lower layer, the receiving UM RLC entity shall: - // -if VR(UR) < x < VR(UH) and the UMD PDU with SN = x has been received before; or - // -if (VR(UH) – UM_Window_Size) <= x < VR(UR): - // -discard the received UMD PDU; - // -else: - // -place the received UMD PDU in the reception buffer. - - rlc_sn_t sn = -1; - signed int in_window; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_RECEIVE_PROCESS_DAR, VCD_FUNCTION_IN); - - if (rlc_pP->rx_sn_length == 10) { - sn = ((pdu_pP->b1 & 0x00000003) << 8) + pdu_pP->b2; - } else if (rlc_pP->rx_sn_length == 5) { - sn = pdu_pP->b1 & 0x1F; - } else { - free_mem_block(pdu_mem_pP, __func__); - pdu_mem_pP = NULL; - return; - } - - RLC_UM_MUTEX_LOCK(&rlc_pP->lock_dar_buffer, ctxt_pP, rlc_pP); - - in_window = rlc_um_in_window(ctxt_pP, rlc_pP, rlc_pP->vr_uh - rlc_pP->rx_um_window_size, sn, rlc_pP->vr_ur); - -#if TRACE_RLC_PAYLOAD - rlc_util_print_hex_octets(RLC, &pdu_pP->b1, tb_sizeP); -#endif - - // rlc_um_in_window() returns -2 if lower_bound > sn - // rlc_um_in_window() returns -1 if higher_bound < sn - // rlc_um_in_window() returns 0 if lower_bound < sn < higher_bound - // rlc_um_in_window() returns 1 if lower_bound == sn - // rlc_um_in_window() returns 2 if higher_bound == sn - // rlc_um_in_window() returns 3 if higher_bound == sn == lower_bound - if ((in_window == 1) || (in_window == 0)) { -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RX PDU VR(UH) – UM_Window_Size) <= SN %d < VR(UR) -> GARBAGE\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn); -#endif - rlc_pP->stat_rx_data_pdu_out_of_window += 1; - rlc_pP->stat_rx_data_bytes_out_of_window += tb_sizeP; - free_mem_block(pdu_mem_pP, __func__); - pdu_mem_pP = NULL; - RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_dar_buffer); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_RECEIVE_PROCESS_DAR, VCD_FUNCTION_OUT); - return; - } - - if ((rlc_um_get_pdu_from_dar_buffer(ctxt_pP, rlc_pP, sn))) { - in_window = rlc_um_in_window(ctxt_pP, rlc_pP, rlc_pP->vr_ur, sn, rlc_pP->vr_uh); - - if (in_window == 0) { -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RX PDU VR(UR) < SN %d < VR(UH) and RECEIVED BEFORE-> GARBAGE\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn); -#endif - //discard the PDU - rlc_pP->stat_rx_data_pdus_duplicate += 1; - rlc_pP->stat_rx_data_bytes_duplicate += tb_sizeP; - free_mem_block(pdu_mem_pP, __func__); - pdu_mem_pP = NULL; - RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_dar_buffer); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_RECEIVE_PROCESS_DAR, VCD_FUNCTION_OUT); - return; - } - - // 2 lines to avoid memory leaks - rlc_pP->stat_rx_data_pdus_duplicate += 1; - rlc_pP->stat_rx_data_bytes_duplicate += tb_sizeP; -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RX PDU SN %03d REMOVE OLD PDU BEFORE STORING NEW PDU\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn); -#endif - mem_block_t *pdu = rlc_um_remove_pdu_from_dar_buffer(ctxt_pP, rlc_pP, sn); - free_mem_block(pdu, __func__); - } - - rlc_um_store_pdu_in_dar_buffer(ctxt_pP, rlc_pP, pdu_mem_pP, sn); - - - // -if x falls outside of the reordering window: - // -update VR(UH) to x + 1; - // -reassemble RLC SDUs from any UMD PDUs with SN that falls outside of - // the reordering window, remove RLC headers when doing so and deliver - // the reassembled RLC SDUs to upper layer in ascending order of the - // RLC SN if not delivered before; - // - // -if VR(UR) falls outside of the reordering window: - // -set VR(UR) to (VR(UH) – UM_Window_Size); - if (rlc_um_in_reordering_window(ctxt_pP, rlc_pP, sn) < 0) { -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RX PDU SN %d OUTSIDE REORDERING WINDOW VR(UH)=%d UM_Window_Size=%d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - sn, - rlc_pP->vr_uh, - rlc_pP->rx_um_window_size); -#endif - rlc_pP->vr_uh = (sn + 1) % rlc_pP->rx_sn_modulo; - - if (rlc_um_in_reordering_window(ctxt_pP, rlc_pP, rlc_pP->vr_ur) != 0) { - in_window = rlc_pP->vr_uh - rlc_pP->rx_um_window_size; - - if (in_window < 0) { - in_window = in_window + rlc_pP->rx_sn_modulo; - } - rlc_um_try_reassembly(ctxt_pP, rlc_pP, rlc_pP->vr_ur, in_window); - } - - - if (rlc_um_in_reordering_window(ctxt_pP, rlc_pP, rlc_pP->vr_ur) < 0) { - //LOG_I(RLC, "[rlc_um_receive_process_dar] Problematic case 4 \n"); -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" VR(UR) %d OUTSIDE REORDERING WINDOW SET TO VR(UH) – UM_Window_Size = %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - rlc_pP->vr_ur, - in_window); -#endif - rlc_pP->vr_ur = in_window; - } - } - - // -if the reception buffer contains an UMD PDU with SN = VR(UR): - // -update VR(UR) to the SN of the first UMD PDU with SN > current - // VR(UR) that has not been received; - // -reassemble RLC SDUs from any UMD PDUs with SN < updated VR(UR), - // remove RLC headers when doing so and deliver the reassembled RLC - // SDUs to upper layer in ascending order of the RLC SN if not - // delivered before; - if ((sn == rlc_pP->vr_ur) && rlc_um_get_pdu_from_dar_buffer(ctxt_pP, rlc_pP, rlc_pP->vr_ur)) { - //sn_tmp = rlc_pP->vr_ur; - do { - rlc_pP->vr_ur = (rlc_pP->vr_ur+1) % rlc_pP->rx_sn_modulo; - } while (rlc_um_get_pdu_from_dar_buffer(ctxt_pP, rlc_pP, rlc_pP->vr_ur) && (rlc_pP->vr_ur != rlc_pP->vr_uh)); - rlc_um_try_reassembly(ctxt_pP, rlc_pP, sn, rlc_pP->vr_ur); - } - - // -if t-Reordering is running: - // -if VR(UX) <= VR(UR); or - // -if VR(UX) falls outside of the reordering window and VR(UX) is not - // equal to VR(UH):: - // -stop and reset t-Reordering; - if (rlc_pP->t_reordering.running) { - if (rlc_pP->vr_uh != rlc_pP->vr_ux) { - in_window = rlc_um_in_reordering_window(ctxt_pP, rlc_pP, rlc_pP->vr_ux); - - if (in_window < 0) { -#if TRACE_RLC_UM_DAR - LOG_D(RLC, - PROTOCOL_RLC_UM_CTXT_FMT" STOP and RESET t-Reordering because VR(UX) falls outside of the reordering window and VR(UX)=%d is not equal to VR(UH)=%d -or- VR(UX) <= VR(UR)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - rlc_pP->vr_ux, - rlc_pP->vr_uh); -#endif - rlc_um_stop_and_reset_timer_reordering(ctxt_pP, rlc_pP); - } - } - } - - if (rlc_pP->t_reordering.running) { - in_window = rlc_um_in_window(ctxt_pP, rlc_pP, rlc_pP->vr_ur, rlc_pP->vr_ux, rlc_pP->vr_uh); - - if ((in_window == -2) || (in_window == 1)) { -#if TRACE_RLC_UM_DAR - LOG_D(RLC, - PROTOCOL_RLC_UM_CTXT_FMT" STOP and RESET t-Reordering because VR(UX) falls outside of the reordering window and VR(UX)=%d is not equal to VR(UH)=%d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - rlc_pP->vr_ux, - rlc_pP->vr_uh); -#endif - rlc_um_stop_and_reset_timer_reordering(ctxt_pP, rlc_pP); - } - } - - // -if t-Reordering is not running (includes the case when t-Reordering is - // stopped due to actions above): - // -if VR(UH) > VR(UR): - // -start t-Reordering; - // -set VR(UX) to VR(UH). - if (rlc_pP->t_reordering.running == 0) { - in_window = rlc_um_in_window(ctxt_pP, rlc_pP, rlc_pP->vr_ur, rlc_pP->vr_uh, rlc_pP->vr_uh); - - if (in_window == 2) { - rlc_um_start_timer_reordering(ctxt_pP, rlc_pP); - rlc_pP->vr_ux = rlc_pP->vr_uh; -#if TRACE_RLC_UM_DAR - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" RESTART t-Reordering set VR(UX) to VR(UH) =%d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - rlc_pP->vr_ux); -#endif - } - } - - RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_dar_buffer); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_RECEIVE_PROCESS_DAR, VCD_FUNCTION_OUT); -} diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.h deleted file mode 100644 index e0dccf2eeec8dc93af5cada0d6214df746d7117e..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_um_dar.h -* \brief This file defines the prototypes of the functions dealing with the reassembly buffer. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_um_receiver_impl_ RLC UM Receiver Implementation -* @ingroup _rlc_um_impl_ -* @{ -*/ -# ifndef __RLC_UM_DAR_H__ -# define __RLC_UM_DAR_H__ -//----------------------------------------------------------------------------- -# include "rlc_um_entity.h" -# include "rlc_um_structs.h" -# include "rlc_um_constants.h" -# include "list.h" -//----------------------------------------------------------------------------- -/*! \fn signed int rlc_um_get_pdu_infos(const protocol_ctxt_t* const ctxt_pP,const rlc_um_entity_t * const rlc_pP,rlc_um_pdu_sn_10_t* header_pP, int16_t total_sizeP, rlc_um_pdu_info_t* pdu_info_pP, uint8_t sn_lengthP) -* \brief Extract PDU informations (header fields, data size, etc) from the serialized PDU. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer.. -* \param[in] header_pP RLC UM header PDU pointer. -* \param[in] total_sizeP Size of RLC UM PDU. -* \param[in] pdu_info_pP Structure containing extracted informations from PDU. -* \param[in] sn_lengthP Sequence number length in bits in PDU header (5 or 10). -* \return 0 if no error was encountered during the parsing of the PDU, else -1; -*/ -signed int rlc_um_get_pdu_infos( - const protocol_ctxt_t* const ctxt_pP, - const rlc_um_entity_t * const rlc_pP, - rlc_um_pdu_sn_10_t * const header_pP, - const sdu_size_t total_sizeP, - rlc_um_pdu_info_t * const pdu_info_pP, - const uint8_t sn_lengthP); - -/*! \fn int rlc_um_read_length_indicators(unsigned char**data_ppP, rlc_um_e_li_t* e_li_pP, unsigned int* li_array_pP, unsigned int *num_li_pP, sdu_size_t *data_size_pP) -* \brief Reset protocol variables and state variables to initial values. -* \param[in,out] data_ppP Pointer on data payload. -* \param[in] e_li_pP Pointer on first LI + e bit in PDU. -* \param[in,out] li_array_pP Array containing read LI. -* \param[in,out] num_li_pP Pointer on number of LI read. -* \param[in,out] data_size_pP Pointer on data size. -* \return 0 if no error was encountered during the parsing of the PDU, else -1; -*/ -int rlc_um_read_length_indicators(unsigned char**data_ppP, rlc_um_e_li_t* e_li_pP, unsigned int* li_array_pP, unsigned int *num_li_pP, sdu_size_t *data_size_pP); - -/*! \fn void rlc_um_try_reassembly (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, rlc_sn_t start_snP, rlc_sn_t end_snP) -* \brief Try reassembly PDUs from DAR buffer, starting at sequence number snP. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] frameP Frame index. -* \param[in] start_snP First PDU to be reassemblied if possible. -* \param[in] end_snP Last excluded highest sequence number of PDU to be reassemblied. -*/ -void rlc_um_try_reassembly (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, const rlc_sn_t start_snP, const rlc_sn_t end_snP); - -/*! \fn void rlc_um_check_timer_reordering(rlc_um_entity_t * const rlc_pP,frame_t frameP) -* \brief Check if timer reordering has timed-out, if so it is stopped and has the status "timed-out". -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] frameP Frame index -*/ -void rlc_um_check_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *const rlc_pP); - -/*! \fn void rlc_um_stop_and_reset_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP) -* \brief Stop and reset the timer reordering. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] frameP Frame index. -*/ -void rlc_um_stop_and_reset_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *const rlc_pP); - -/*! \fn void rlc_um_start_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP) -* \brief Re-arm (based on RLC UM config parameter) and start timer reordering. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] frameP Frame index. -*/ -void rlc_um_start_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP); - -/*! \fn void rlc_um_init_timer_reordering(rlc_um_entity_t * const rlc_pP, const uint32_t ms_durationP) -* \brief Initialize the timer reordering with RLC UM time-out config parameter. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] ms_durationP Duration in milliseconds units. -*/ -void rlc_um_init_timer_reordering(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, const uint32_t ms_durationP); - -/*! \fn void rlc_um_check_timer_dar_time_out(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP,) -* \brief Check if t-Reordering expires and take the appropriate actions as described in 3GPP specifications. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -*/ -void rlc_um_check_timer_dar_time_out(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP); - -/*! \fn mem_block_t *rlc_um_remove_pdu_from_dar_buffer(rlc_um_entity_t * const rlc_pP, uint16_t snP) -* \brief Remove the PDU with sequence number snP from the DAR buffer and return it. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] snP Sequence number. -* \return The PDU stored in the DAR buffer having sequence number snP, else return NULL. -*/ -mem_block_t *rlc_um_remove_pdu_from_dar_buffer(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, const uint16_t snP); - -/*! \fn mem_block_t *rlc_um_remove_pdu_from_dar_buffer(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, const uint16_t snP) -* \brief Get the PDU with sequence number snP from the DAR buffer. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] snP Sequence number. -* \return The PDU stored in the DAR buffer having sequence number snP, else return NULL. -*/ -mem_block_t* rlc_um_get_pdu_from_dar_buffer(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, const uint16_t snP); - -/*! \fn signed int rlc_um_in_window(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP,rlc_sn_t lower_boundP, rlc_sn_t snP, rlc_sn_t higher_boundP) -* \brief Compute if the sequence number of a PDU is in a window . -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] lower_boundP Lower bound of a window. -* \param[in] snP Sequence number of a theorical PDU. -* \param[in] higher_boundP Higher bound of a window. -* \return -2 if lower_boundP > sn, -1 if higher_boundP < sn, 0 if lower_boundP < sn < higher_boundP, 1 if lower_boundP == sn, 2 if higher_boundP == sn, 3 if higher_boundP == sn == lower_boundP. -*/ -signed int rlc_um_in_window(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, const rlc_sn_t lower_boundP, const rlc_sn_t snP, const rlc_sn_t higher_boundP); - -/*! \fn signed int rlc_um_in_reordering_window(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, const rlc_sn_t snP) -* \brief Compute if the sequence number of a PDU is in a window . -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] snP Sequence number of a theorical PDU. -* \return 0 if snP is in reordering window, else -1. -*/ -signed int rlc_um_in_reordering_window(const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, const rlc_sn_t snP); - -/*! \fn void rlc_um_receive_process_dar (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, mem_block_t *pdu_mem_pP,rlc_um_pdu_sn_10_t * const pdu_pP, const sdu_size_t tb_sizeP) -* \brief Apply the DAR process for a PDU: put it in DAR buffer and try to reassembly or discard it. -* \param[in] ctxt_pP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] pdu_mem_pP mem_block_t wrapper for a UM PDU . -* \param[in] pdu_pP Pointer on the header of the UM PDU. -* \param[in] tb_sizeP Size of the UM PDU. -*/ -void rlc_um_receive_process_dar (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP, mem_block_t * pdu_mem_pP,rlc_um_pdu_sn_10_t * const pdu_pP, - const sdu_size_t tb_sizeP); -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h deleted file mode 100644 index 34ead658224749ef75e329b5baa11fba4bbe155b..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_um_entity.h -* \brief This file defines the RLC UM variables stored in a struct called rlc_um_entity_t. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note The rlc_um_entity_t structure store protocol variables, statistic variables, allocation variables, buffers and other miscellaneous variables. -* \bug -* \warning -*/ -# ifndef __RLC_UM_ENTITY_H__ -# define __RLC_UM_ENTITY_H__ - -# include <pthread.h> -# include "platform_types.h" -#include "common/platform_constants.h" -# include "list.h" -# include "rlc_primitives.h" -# include "rlc_def.h" - -typedef struct rlc_um_timer_s { - uint32_t ms_time_out; /*!< \brief When set, indicate the time the timer will time-out. */ - uint32_t ms_start; /*!< \brief indicate the time the timer has been started. */ - uint32_t ms_duration; /*!< \brief Configured timer duration in frames. */ - uint32_t running:1; /*!< \brief The timer is running. */ - uint32_t timed_out:1; /*!< \brief The timer has timed-out. */ - uint32_t dummy:30; /*!< \brief Bits not used. */ -} rlc_um_timer_t ; - - -/*! \struct rlc_um_entity_s -* \brief Structure containing a RLC UM instance protocol variables, statistic variables, allocation variables, buffers and other miscellaneous variables. -*/ - -typedef struct rlc_um_entity_s { - bool initialized; /*!< \brief Boolean for rlc_am_entity_t struct initialization. */ - bool is_uplink_downlink; /*!< \brief Is this instance is a transmitter, a receiver or both? */ - rlc_protocol_state_t protocol_state; /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE, RLC_LOCAL_SUSPEND_STATE. */ - bool is_data_plane; /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */ - bool is_mxch; /*!< \brief To know if the RLC belongs to a MBMS bearer. */ - //----------------------------- - // PROTOCOL VARIABLES - //----------------------------- - rlc_usn_t - vt_us; /*!< \brief This state variable holds the value of the SN to be assigned for the next newly generated UMD PDU. It is initially set to 0, and is updated whenever the UM RLC entity delivers an UMD PDU with SN = VT(US). */ - rlc_usn_t - vr_ur; /*!< \brief UM receive state variable. This state variable holds the value of the SN of the earliest UMD PDU that is still considered for reordering. It is initially set to 0. */ - rlc_usn_t vr_ux; /*!< \brief UM t-Reordering state variable. This state variable holds the value of the SN following the SN of the UMD PDU which triggered t-Reordering. */ - rlc_usn_t - vr_uh; /*!< \brief UM highest received state variable. This state variable holds the value of the SN following the SN of the UMD PDU with the highest SN among received UMD PDUs, and it serves as the higher edge of the reordering window. It is initially set to 0. */ - //----------------------------- - // TIMERS - //----------------------------- - struct rlc_um_timer_s t_reordering; - //***************************************************************************** - // CONFIGURATION PARAMETERS - //***************************************************************************** - uint8_t tx_sn_length; /*!< \brief Length of sequence number in bits, can be 5 or 10. */ - uint8_t rx_sn_length; /*!< \brief Length of sequence number in bits, can be 5 or 10. */ - uint8_t tx_header_min_length_in_bytes; /*!< \brief Length of PDU header, can be 1 or 2 bytes. */ - uint8_t rx_header_min_length_in_bytes; /*!< \brief Length of PDU header, can be 1 or 2 bytes. */ - rlc_sn_t tx_sn_modulo; /*!< \brief Module of the sequence number of PDU, can be RLC_UM_SN_5_BITS_MODULO or RLC_UM_SN_10_BITS_MODULO. */ - rlc_sn_t rx_sn_modulo; /*!< \brief Module of the sequence number of PDU, can be RLC_UM_SN_5_BITS_MODULO or RLC_UM_SN_10_BITS_MODULO. */ - rlc_sn_t rx_um_window_size; - rlc_sn_t tx_um_window_size; - //----------------------------- - // tranmission - //----------------------------- - // sdu communication; - //pthread_spinlock_t lock_input_sdus; - pthread_mutex_t lock_input_sdus; - list_t input_sdus; /*!< \brief Input SDU buffer (for SDUs coming from upper layers). Should be accessed as an array. */ - 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. */ - //***************************************************************************** - // RECEIVER - //***************************************************************************** - mem_block_t *output_sdu_in_construction; /*!< \brief Memory area where a complete SDU is reassemblied before being send to upper layers. */ - sdu_size_t output_sdu_size_to_write; /*!< \brief Size of the reassemblied SDU. */ - - - //pthread_spinlock_t lock_dar_buffer; - pthread_mutex_t lock_dar_buffer; - mem_block_t **dar_buffer; /*!< \brief Array of rx PDUs. */ - list_t pdus_from_mac_layer; /*!< \brief Not Used. */ - - logical_chan_id_t channel_id; /*!< \brief Transport channel identifier. */ - rb_id_t rb_id; /*!< \brief Radio bearer identifier, for statistics and trace purpose. */ - rlc_usn_t last_reassemblied_sn; /*!< \brief Sequence number of the last reassemblied PDU. */ - rlc_usn_t last_reassemblied_missing_sn; /*!< \brief Sequence number of the last found missing PDU. */ - rlc_usn_t reassembly_missing_sn_detected; /*!< \brief Act as a boolean, set if a hole in the sequence numbering of received PDUs has been found. */ - //----------------------------- - // STATISTICS - //----------------------------- - bool first_pdu; /*!< \brief Act as a boolean, tells if the next PDU is the first PDU to be received. */ - - unsigned int stat_tx_pdcp_sdu; /*!< \brief Number of SDUs received from upper layers. */ - unsigned int stat_tx_pdcp_bytes; /*!< \brief Number of SDU bytes received from upper layers. */ - unsigned int stat_tx_pdcp_sdu_discarded; /*!< \brief Number of SDUs received from upper layers that have been discarded. */ - unsigned int stat_tx_pdcp_bytes_discarded; /*!< \brief Number of SDU bytes received from upper layers that have been discarded. */ - - unsigned int stat_tx_data_pdu; /*!< \brief For statistic report, number of transmitted PDUs to lower layers. */ - unsigned int stat_tx_data_bytes; /*!< \brief For statistic report, number of transmitted bytes to lower layers. */ - unsigned int stat_rx_pdcp_sdu; /*!< \brief For statistic report, number of reassemblied SDUs, sent to upper layers. */ - unsigned int stat_rx_pdcp_bytes; /*!< \brief For statistic report, number of reassemblied bytes, sent to upper layers. */ - unsigned int stat_rx_data_pdus_duplicate; /*!< \brief For statistic report, number of received duplicated PDUs from lower layers. */ - unsigned int stat_rx_data_bytes_duplicate; /*!< \brief For statistic report, number of received duplicated bytes from lower layers. */ - unsigned int stat_rx_data_pdu; /*!< \brief For statistic report, number of received PDUs from lower layers. */ - unsigned int stat_rx_data_bytes; /*!< \brief For statistic report, number of received bytes from lower layers. */ - unsigned int stat_rx_data_pdu_dropped; /*!< \brief For statistic report, number of dropped received PDUs from lower layers. Does not include out of window stat. */ - unsigned int stat_rx_data_bytes_dropped; /*!< \brief For statistic report, number of dropped received bytes from lower layers. Does not include out of window stat. */ - unsigned int stat_rx_data_pdu_out_of_window; /*!< \brief Number of data PDUs received out of the receive window. */ - unsigned int stat_rx_data_bytes_out_of_window; /*!< \brief Number of data bytes received out of the receive window. */ - unsigned int stat_timer_reordering_timed_out; -} rlc_um_entity_t; -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c deleted file mode 100644 index b8ac29fca4c92d20fa0c1fd21b807ec69893fec1..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_UM_MODULE 1 -#define RLC_UM_FSM_C 1 -#include "platform_types.h" -//----------------------------------------------------------------------------- -#include "rlc_um.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" - - -//----------------------------------------------------------------------------- -int -rlc_um_fsm_notify_event ( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t *rlc_pP, uint8_t eventP) -{ - - switch (rlc_pP->protocol_state) { - //------------------------------- - // RLC_NULL_STATE - //------------------------------- - case RLC_NULL_STATE: - switch (eventP) { - case RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT: - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM RLC_NULL_STATE -> RLC_DATA_TRANSFER_READY_STATE\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - rlc_pP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; - return 1; - break; - - default: - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM NULL_STATE\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - eventP); - //AssertFatal(1==0,"RLC-UM FSM WARNING PROTOCOL ERROR - EVENT NOT EXPECTED FROM NULL_STATE"); - return 0; - } - - break; - - //------------------------------- - // RLC_DATA_TRANSFER_READY_STATE - //------------------------------- - case RLC_DATA_TRANSFER_READY_STATE: - switch (eventP) { - case RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_NULL_STATE_EVENT: - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM RLC_DATA_TRANSFER_READY_STATE -> RLC_NULL_STATE\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - rlc_pP->protocol_state = RLC_NULL_STATE; - return 1; - break; - - case RLC_UM_RECEIVE_CRLC_SUSPEND_REQ_EVENT: - case RLC_UM_TRANSMIT_CRLC_SUSPEND_CNF_EVENT: - LOG_I(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM RLC_DATA_TRANSFER_READY_STATE -> RLC_LOCAL_SUSPEND_STATE\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - rlc_pP->protocol_state = RLC_LOCAL_SUSPEND_STATE; - return 1; - break; - - default: - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM DATA_TRANSFER_READY_STATE\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - eventP); - return 0; - } - - break; - - //------------------------------- - // RLC_LOCAL_SUSPEND_STATE - //------------------------------- - case RLC_LOCAL_SUSPEND_STATE: - switch (eventP) { - case RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_NULL_STATE_EVENT: - LOG_I(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM RLC_LOCAL_SUSPEND_STATE -> RLC_NULL_STATE\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - rlc_pP->protocol_state = RLC_NULL_STATE; - return 1; - break; - - case RLC_UM_RECEIVE_CRLC_RESUME_REQ_EVENT: - LOG_I(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM RLC_LOCAL_SUSPEND_STATE -> RLC_DATA_TRANSFER_READY_STATE\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP)); - rlc_pP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; - return 1; - break; - - default: - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM RLC_LOCAL_SUSPEND_STATE\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - eventP); - return 0; - } - - break; - - default: - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM ERROR UNKNOWN STATE %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - rlc_pP->protocol_state); - return 0; - } -} diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.h deleted file mode 100644 index 14ad253dcc9bc1b45780b4d6d660e15ba2ff2ae9..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_um_fsm.h -* \brief This file defines the prototypes of the functions dealing with the finite state machine of the RLC UM protocol instance. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_um_fsm_impl_ RLC UM FSM Implementation -* @ingroup _rlc_um_impl_ -* @{ -*/ -# ifndef __RLC_UM_FSM_PROTO_EXTERN_H__ -# define __RLC_UM_FSM_PROTO_EXTERN_H__ -//----------------------------------------------------------------------------- -# include "platform_types.h" -# include "rlc_um_entity.h" -//----------------------------------------------------------------------------- -/*! \fn int rlc_um_fsm_notify_event (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlcP, uint8_t eventP) -* \brief Send an event to the RLC UM finite state machine. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] eventP Event (#RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_NULL_STATE_EVENT, -* #RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT, -* #RLC_UM_RECEIVE_CRLC_SUSPEND_REQ_EVENT, -* #RLC_UM_TRANSMIT_CRLC_SUSPEND_CNF_EVENT, -* #RLC_UM_RECEIVE_CRLC_RESUME_REQ_EVENT). -* \return 1 if no error was encountered, 0 if the event was not processed. -* \Note This FSM is not LTE 9.3.0 compliant, it has to be modified or removed. -*/ -int rlc_um_fsm_notify_event (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlcP, uint8_t eventP); -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c deleted file mode 100644 index ca43dab667f4dfafbac196cfa433bedb6feaf256..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_UM_MODULE 1 -#define RLC_UM_REASSEMBLY_C 1 -#include "platform_types.h" -//----------------------------------------------------------------------------- -#include <string.h> -#if ENABLE_ITTI -# include "platform_types.h" -# include "intertask_interface.h" -#endif -#include "assertions.h" -#include "rlc.h" -#include "rlc_um.h" -#include "rlc_primitives.h" -#include "list.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" - -//----------------------------------------------------------------------------- -inline void -rlc_um_clear_rx_sdu (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t* rlc_pP) -{ - rlc_pP->output_sdu_size_to_write = 0; -} - -//----------------------------------------------------------------------------- -void -rlc_um_reassembly (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP, uint8_t * src_pP, int32_t lengthP) -{ - sdu_size_t sdu_max_size; - - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[REASSEMBLY] reassembly() %d bytes %d bytes already reassemblied\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - lengthP, - rlc_pP->output_sdu_size_to_write); - - if (lengthP <= 0) { - return; - } - - if ((rlc_pP->is_data_plane)) { - sdu_max_size = RLC_SDU_MAX_SIZE_DATA_PLANE; - } else { - sdu_max_size = RLC_SDU_MAX_SIZE_CONTROL_PLANE; - } - - if (rlc_pP->output_sdu_in_construction == NULL) { - // msg("[RLC_UM_LITE] Getting mem_block ...\n"); - rlc_pP->output_sdu_in_construction = get_free_mem_block (sdu_max_size, __func__); - rlc_pP->output_sdu_size_to_write = 0; - } - - if ((rlc_pP->output_sdu_in_construction)) { - // check if no overflow in size - if ((rlc_pP->output_sdu_size_to_write + lengthP) <= sdu_max_size) { - memcpy (&rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write], src_pP, lengthP); - rlc_pP->output_sdu_size_to_write += lengthP; -#if TRACE_RLC_UM_DISPLAY_ASCII_DATA - rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write] = 0; - LOG_T(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[REASSEMBLY] DATA :", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); - rlc_util_print_hex_octets(RLC, (unsigned char*)rlc_pP->output_sdu_in_construction->data, rlc_pP->output_sdu_size_to_write); -#endif - } else { -#if STOP_ON_IP_TRAFFIC_OVERLOAD - AssertFatal(0, PROTOCOL_RLC_UM_CTXT_FMT" RLC_UM_DATA_IND, SDU TOO BIG, DROPPED\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); -#endif - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[REASSEMBLY] [max_sdu size %d] ERROR SDU SIZE OVERFLOW SDU GARBAGED\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_max_size); - // erase SDU - rlc_pP->output_sdu_size_to_write = 0; - } - } else { - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[REASSEMBLY]ERROR OUTPUT SDU IS NULL\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); -#if STOP_ON_IP_TRAFFIC_OVERLOAD - AssertFatal(0, PROTOCOL_RLC_UM_CTXT_FMT" RLC_UM_DATA_IND, SDU DROPPED, OUT OF MEMORY\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); -#endif - } - -} -//----------------------------------------------------------------------------- -void -rlc_um_send_sdu (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP) -{ - if ((rlc_pP->output_sdu_in_construction)) { - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" SEND_SDU to upper layers %d bytes sdu %p\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->output_sdu_size_to_write, - rlc_pP->output_sdu_in_construction); - - if (rlc_pP->output_sdu_size_to_write > 0) { - rlc_pP->stat_rx_pdcp_sdu += 1; - rlc_pP->stat_rx_pdcp_bytes += rlc_pP->output_sdu_size_to_write; - -#if TEST_RLC_UM -#if TRACE_RLC_UM_DISPLAY_ASCII_DATA - rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write] = 0; - LOG_T(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[SEND_SDU] DATA :", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); - rlc_util_print_hex_octets(RLC, rlc_pP->output_sdu_in_construction->data, rlc_pP->output_sdu_size_to_write); -#endif - rlc_um_v9_3_0_test_data_ind (rlc_pP->module_id, rlc_pP->rb_id, rlc_pP->output_sdu_size_to_write, rlc_pP->output_sdu_in_construction); -#else - // msg("[RLC] DATA IND ON MOD_ID %d RB ID %d, size %d\n",rlc_pP->module_id, rlc_pP->rb_id, ctxt_pP->frame,rlc_pP->output_sdu_size_to_write); - rlc_data_ind ( - ctxt_pP, - BOOL_NOT(rlc_pP->is_data_plane), - rlc_pP->is_mxch, - rlc_pP->rb_id, - rlc_pP->output_sdu_size_to_write, - rlc_pP->output_sdu_in_construction); -#endif - rlc_pP->output_sdu_in_construction = NULL; - } else { - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[SEND_SDU] ERROR SIZE <= 0 ... DO NOTHING, SET SDU SIZE TO 0\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); - } - - rlc_pP->output_sdu_size_to_write = 0; - } -} diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.h deleted file mode 100644 index defdd1364e3d309cfdbc5fec69d93277ee671b1e..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_um_reassembly.h -* \brief This file defines the prototypes of the functions dealing with the reassembly of segments. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_um_receiver_impl_ RLC UM Receiver Implementation -* @ingroup _rlc_um_impl_ -* @{ -*/ -# ifndef __RLC_UM_REASSEMBLY_PROTO_EXTERN_H__ -# define __RLC_UM_REASSEMBLY_PROTO_EXTERN_H__ -//----------------------------------------------------------------------------- -# include "rlc_um_entity.h" -//----------------------------------------------------------------------------- -/*! \fn void rlc_um_clear_rx_sdu (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlcP) -* \brief Erase the SDU in construction. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC UM protocol instance pointer. -*/ -void rlc_um_clear_rx_sdu (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlcP); - -/*! \fn void rlc_um_reassembly (uint8_t * srcP, int32_t lengthP, rlc_um_entity_t *rlcP, frame_t frame) -* \brief Reassembly lengthP bytes to the end of the SDU in construction. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] srcP Pointer on data to be reassemblied. -* \param[in] lengthP Length to reassembly. -*/ -void rlc_um_reassembly (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlcP, uint8_t * srcP, int32_t lengthP); - -/*! \fn void rlc_um_send_sdu (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlcP) -* \brief Send SDU if any reassemblied to upper layer. -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC UM protocol instance pointer. -*/ -void rlc_um_send_sdu (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlcP); -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c deleted file mode 100644 index 90e006cd1782bdacc9b78d8213fbf1fa16ea78dd..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_UM_MODULE 1 -#define RLC_UM_RECEIVER_C 1 -#include "platform_types.h" -//----------------------------------------------------------------------------- -#include "rlc.h" -#include "rlc_um.h" -#include "rlc_um_structs.h" -#include "rlc_primitives.h" -#include "mac_primitives.h" -#include "list.h" -#include "common/utils/LOG/log.h" - -//----------------------------------------------------------------------------- -void -rlc_um_display_rx_window( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t * const rlc_pP -) -{ - unsigned long sn = 0; - unsigned long end_sn = 0; - LOG_USEDINLOG_VAR(char,str[4]); - char time_out_str[11]; - int str_index; - char color[32]; - - LOG_T(RLC, "\n"); - LOG_T(RLC, "+-------------------------------------------------------------------------------------------------------+"); - LOG_T(RLC, "\n"); - sprintf(time_out_str, "%010d", rlc_pP->t_reordering.ms_duration); - time_out_str[10] = 0; - LOG_T(RLC, "| RLC UM RB %02ld VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d t-Reordering: %s %s %s |", - rlc_pP->rb_id, rlc_pP->vr_ur, rlc_pP->vr_ux, rlc_pP->vr_uh, - (rlc_pP->t_reordering.running)?" ON":"OFF", - (rlc_pP->t_reordering.running)?"Time-out frameP:":" ", - (rlc_pP->t_reordering.running)?time_out_str:" "); - LOG_T(RLC, "\n"); - LOG_T(RLC, "+------+------------------------------------------------------------------------------------------------+"); - LOG_T(RLC, "\n"); - LOG_T(RLC, "| |00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |"); - LOG_T(RLC, "\n"); - LOG_T(RLC, "+------+------------------------------------------------------------------------------------------------+"); - LOG_T(RLC, "\n"); - - if (rlc_pP->rx_sn_length == 10) { - end_sn = RLC_UM_SN_10_BITS_MODULO; - } else { - end_sn = RLC_UM_SN_5_BITS_MODULO; - } - - - for (sn = 0; sn < end_sn; sn++) { - str[0] = ' '; - str[1] = ' '; - str[2] = ' '; - str[3] = 0; - str_index = 0; - - if ((sn % 32) == 0) { - if ((sn != 0)) { - LOG_T(RLC, "%s%s|", RLC_FG_COLOR_DEFAULT, RLC_NORMAL_VIDEO); - LOG_T(RLC, "\n"); - } - - LOG_T(RLC, "%s%s| %04lu |", RLC_FG_COLOR_DEFAULT, RLC_NORMAL_VIDEO, sn); - } - - strcpy(color, RLC_FG_COLOR_DEFAULT); - - if (sn == rlc_pP->vr_ur) { - str[str_index++] = 'R'; - strcpy(color, RLC_FG_COLOR_BLUE); - } - - if (sn == rlc_pP->vr_ux) { - str[str_index++] = 'X'; - strcpy(color, RLC_FG_COLOR_ORANGE); - } - - if (sn == rlc_pP->vr_uh) { - str[str_index++] = 'H'; - strcpy(color, RLC_FG_COLOR_RED); - } - - if (rlc_um_get_pdu_from_dar_buffer(ctxt_pP, rlc_pP, sn)) { - // test RLC_REVERSE_VIDEO - if (str_index <= 2) { - str[str_index] = '.'; - } - - LOG_T(RLC, "%s%s%s", color, RLC_REVERSE_VIDEO, str); - } else { - LOG_T(RLC, "%s%s%s", color, RLC_NORMAL_VIDEO, str); - } - } - - LOG_T(RLC, "%s%s|", RLC_FG_COLOR_DEFAULT, RLC_NORMAL_VIDEO); - LOG_T(RLC, "\n"); - LOG_T(RLC, "+------+------------------------------------------------------------------------------------------------+"); - LOG_T(RLC, "\n"); -} - -//----------------------------------------------------------------------------- -void -rlc_um_receive ( - const protocol_ctxt_t* const ctxt_pP, - rlc_um_entity_t * const rlc_pP, - struct mac_data_ind data_indP) -{ - - mem_block_t *tb_p = NULL; - uint8_t *first_byte_p = NULL; - uint16_t tb_size_in_bytes = 0; - - while ((tb_p = list_remove_head (&data_indP.data))) { - - first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr; - tb_size_in_bytes = ((struct mac_tb_ind *) (tb_p->data))->size; - - rlc_pP->stat_rx_data_bytes += tb_size_in_bytes; - rlc_pP->stat_rx_data_pdu += 1; - - if (tb_size_in_bytes > 0) { - rlc_um_receive_process_dar (ctxt_pP, rlc_pP, tb_p, (rlc_um_pdu_sn_10_t*)first_byte_p, tb_size_in_bytes); -#if defined(TRACE_RLC_UM_RX) - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - rlc_pP->vr_ur, - rlc_pP->vr_ux, - rlc_pP->vr_uh); - //rlc_um_display_rx_window(rlc_pP); commented because bad display -#endif - } - } -} diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.h deleted file mode 100644 index 84df8ac77c599ab836f9a19f6d4cd7d1064f5f1e..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_um_receiver.h -* \brief This file defines the prototypes of the functions dealing with the first stage of the receiving process. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @addtogroup _rlc_um_receiver_impl_ RLC UM Receiver Implementation -* @{ -*/ -# ifndef __RLC_UM_RECEIVER_PROTO_EXTERN_H__ -# define __RLC_UM_RECEIVER_PROTO_EXTERN_H__ -# include "rlc_um_entity.h" -# include "mac_primitives.h" - -/*! \fn void rlc_um_display_rx_window(const protocol_ctxt_t* const ctxtP,rlc_um_entity_t * const rlc_pP) -* \brief Display the content of the RX buffer, the output stream is targeted to TTY terminals because of escape sequences. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -*/ -void rlc_um_display_rx_window(const protocol_ctxt_t* const ctxtP, rlc_um_entity_t * const rlc_pP); - -/*! \fn void rlc_um_receive (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t * const rlc_pP, struct mac_data_ind data_indP) -* \brief Handle the MAC data indication, retreive the transport blocks and send them one by one to the DAR process. -* \param[in] ctxtP Running context. -* \param[in] rlc_pP RLC UM protocol instance pointer. -* \param[in] data_indP Data indication structure containing transport block received from MAC layer. -*/ -void rlc_um_receive (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t * const rlc_pP, struct mac_data_ind data_indP); -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c deleted file mode 100644 index 5252a8a1212198f3f1471a80acdf0d2a232e9175..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c +++ /dev/null @@ -1,808 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_UM_MODULE 1 -#define RLC_UM_SEGMENT_C 1 -//----------------------------------------------------------------------------- -#include "platform_types.h" -#include "common/platform_constants.h" -//----------------------------------------------------------------------------- -#include <assert.h> -#include "assertions.h" -#include "list.h" -#include "rlc_um.h" -#include "rlc_primitives.h" -#include "common/utils/LOG/log.h" - -//----------------------------------------------------------------------------- -void -rlc_um_segment_10 (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP) -{ - list_t pdus; - signed int pdu_remaining_size; - signed int test_pdu_remaining_size; - - int nb_bytes_to_transmit = rlc_pP->nb_bytes_requested_by_mac; - rlc_um_pdu_sn_10_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; - mem_block_t *sdu_in_buffer = NULL; - 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; - - if (nb_bytes_to_transmit < 3) { -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" NO SEGMENTATION nb_bytes to transmit = %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - nb_bytes_to_transmit); -#endif - return; - } - - list_init (&pdus, NULL); // param string identifying the list is NULL - pdu_mem_p = NULL; - - // not fine locking - RLC_UM_MUTEX_LOCK(&rlc_pP->lock_input_sdus, ctxt_pP, rlc_pP); - - while ((list_get_head(&rlc_pP->input_sdus)) && (nb_bytes_to_transmit > 0)) { - -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" nb_bytes_to_transmit %d BO %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - nb_bytes_to_transmit, - rlc_pP->buffer_occupancy); -#endif - - // pdu_p management - if (!pdu_mem_p) { - if (rlc_pP->input_sdus.nb_elements <= 1) { - max_li_overhead = 0; - } else { - 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; -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - data_pdu_size); -#endif - } else { - data_pdu_size = nb_bytes_to_transmit; -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - data_pdu_size); -#endif - } - - if (!(pdu_mem_p = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req), __func__))) { -#if TRACE_RLC_UM_SEGMENT - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" ERROR COULD NOT GET NEW PDU, EXIT\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); -#endif - RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); - return; - } - -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" get new PDU %d bytes\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - data_pdu_size); -#endif - pdu_remaining_size = data_pdu_size - 2; - pdu_p = (rlc_um_pdu_sn_10_t*) (&pdu_mem_p->data[sizeof(struct mac_tb_req)]); - pdu_tb_req_p = (struct mac_tb_req*) (pdu_mem_p->data); - - memset (pdu_mem_p->data, 0, sizeof (rlc_um_pdu_sn_10_t)+sizeof(struct mac_tb_req)); - li_length_in_bytes = 1; - } - - //---------------------------------------- - // compute how many SDUS can fill the PDU - //---------------------------------------- - continue_fill_pdu_with_sdu = 1; - num_fill_sdu = 0; - test_num_li = 0; - 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 ((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 - continue_fill_pdu_with_sdu = 0; - num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - } else if (sdu_mngt_p->sdu_remaining_size == test_pdu_remaining_size) { - // fi will indicate end of PDU is end of SDU, no need for LI - continue_fill_pdu_with_sdu = 0; - num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - } else if ((sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) == test_pdu_remaining_size ) { - // no LI - continue_fill_pdu_with_sdu = 0; - num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - //pdu_remaining_size = pdu_remaining_size - (test_li_length_in_bytes ^ 3); - } else if ((sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) < test_pdu_remaining_size ) { - test_num_li += 1; - num_fill_sdu += 1; - test_pdu_remaining_size = test_pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)); - test_remaining_size_to_substract = test_li_length_in_bytes ^ 3; - test_remaining_num_li_to_substract = 1; - test_li_length_in_bytes = test_li_length_in_bytes ^ 3; - } else { -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" sdu_mngt_p->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p->sdu_remaining_size, - test_pdu_remaining_size, - test_li_length_in_bytes ^ 3); -#endif - // reduce the size of the PDU - continue_fill_pdu_with_sdu = 0; - num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - pdu_remaining_size = pdu_remaining_size - 1; - } - - sdu_in_buffer = sdu_in_buffer->next; - } - - if (test_remaining_num_li_to_substract > 0) { - // there is a LI that is not necessary - test_num_li = test_num_li - 1; - pdu_remaining_size = pdu_remaining_size - test_remaining_size_to_substract; - } - - //---------------------------------------- - // Do the real filling of the pdu_p - //---------------------------------------- -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" data shift %d Bytes num_li %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - ((test_num_li*3) +1) >> 1, - test_num_li); -#endif - - data = ((char*)(&pdu_p->data[((test_num_li*3) +1) >> 1])); - e_li_p = (rlc_um_e_li_t*)(pdu_p->data); - continue_fill_pdu_with_sdu = 1; - li_length_in_bytes = 1; - fill_num_li = 0; - 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 *) (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 ((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 TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p, - sdu_mngt_p->sdu_remaining_size); -#endif - } else { -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes \n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p, - sdu_mngt_p->sdu_remaining_size, - sdu_mngt_p->sdu_size); -#endif - } - - data_sdu_p = (char *) &(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 TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling all remaining PDU with %d bytes\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_remaining_size); - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" pdu_mem_p %p pdu_mem_p->data %p pdu_p %p pdu_p->data %p data %p data_sdu_p %p pdu_remaining_size %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_mem_p, - pdu_mem_p->data, - pdu_p, - pdu_p->data, - data, - data_sdu_p, - pdu_remaining_size); -#endif - - memcpy(data, data_sdu_p, pdu_remaining_size); - sdu_mngt_p->sdu_remaining_size = sdu_mngt_p->sdu_remaining_size - pdu_remaining_size; - sdu_mngt_p->sdu_segmented_size = sdu_mngt_p->sdu_segmented_size + pdu_remaining_size; - fi_last_byte_pdu_is_last_byte_sdu = 0; - // no LI - rlc_pP->buffer_occupancy -= pdu_remaining_size; - continue_fill_pdu_with_sdu = 0; - pdu_remaining_size = 0; - } else if (sdu_mngt_p->sdu_remaining_size == pdu_remaining_size) { -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Exactly Filling remaining PDU with %d remaining bytes of SDU\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_remaining_size); -#endif - memcpy(data, data_sdu_p, pdu_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, __func__); - 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 - continue_fill_pdu_with_sdu = 0; - pdu_remaining_size = 0; - } else if ((sdu_mngt_p->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling PDU with %d all remaining bytes of SDU\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p->sdu_remaining_size); -#endif - memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); - data = &data[sdu_mngt_p->sdu_remaining_size]; - li_length_in_bytes = li_length_in_bytes ^ 3; - fill_num_li += 1; - - if (li_length_in_bytes == 2) { - if (fill_num_li == test_num_li) { - //e_li_p->e1 = 0; - e_li_p->b1 = 0; - } else { - //e_li_p->e1 = 1; - e_li_p->b1 = 0x80; - } - - //e_li_p->li1 = sdu_mngt_p->sdu_remaining_size; - e_li_p->b1 = e_li_p->b1 | (sdu_mngt_p->sdu_remaining_size >> 4); - e_li_p->b2 = sdu_mngt_p->sdu_remaining_size << 4; -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" set e_li_p->b1=%02X set e_li_p->b2=%02X fill_num_li=%d test_num_li=%d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - e_li_p->b1, - e_li_p->b2, - fill_num_li, - test_num_li); -#endif - } else { - if (fill_num_li != test_num_li) { - //e_li_p->e2 = 1; - e_li_p->b2 = e_li_p->b2 | 0x08; - } - - //e_li_p->li2 = sdu_mngt_p->sdu_remaining_size; - e_li_p->b2 = e_li_p->b2 | (sdu_mngt_p->sdu_remaining_size >> 8); - e_li_p->b3 = sdu_mngt_p->sdu_remaining_size & 0xFF; -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" set e_li_p->b2=%02X set e_li_p->b3=%02X fill_num_li=%d test_num_li=%d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - e_li_p->b2, - e_li_p->b3, - fill_num_li, - test_num_li); -#endif - 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; - sdu_in_buffer = list_remove_head(&rlc_pP->input_sdus); - free_mem_block (sdu_in_buffer, __func__); - sdu_in_buffer = list_get_head(&rlc_pP->input_sdus); - sdu_mngt_p = NULL; - - } else { -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p->sdu_remaining_size, - pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); -#endif - memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); - // 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, __func__); - sdu_in_buffer = list_get_head(&rlc_pP->input_sdus); - sdu_mngt_p = NULL; - - } - } - - // set framing info - if (fi_first_byte_pdu_is_first_byte_sdu) { - fi = 0; - } else { - fi = 2; - } - - if (!fi_last_byte_pdu_is_last_byte_sdu) { - fi = fi + 1; - } - - pdu_p->b1 = (fi << 3); //pdu_p->b1 | - - // set fist e bit - if (fill_num_li > 0) { - pdu_p->b1 = pdu_p->b1 | 0x04; - } - - pdu_p->b1 = pdu_p->b1 | ((rlc_pP->vt_us >> 8) & 0x03); - pdu_p->b2 = rlc_pP->vt_us & 0xFF; - rlc_pP->vt_us = rlc_pP->vt_us+1; - - pdu_tb_req_p->data_ptr = (unsigned char*)pdu_p; - pdu_tb_req_p->tb_size = data_pdu_size - pdu_remaining_size; - list_add_tail_eurecom (pdu_mem_p, &rlc_pP->pdus_to_mac_layer); -#if TRACE_RLC_PAYLOAD - rlc_util_print_hex_octets(RLC, pdu_mem_p->data, data_pdu_size); -#endif - //AssertFatal( pdu_tb_req_p->tb_size > 0 , "SEGMENT10: FINAL RLC UM PDU LENGTH %d", pdu_tb_req_p->tb_size); - if(pdu_tb_req_p->tb_size <= 0) { - LOG_E(RLC, "SEGMENT10: FINAL RLC UM PDU LENGTH %d\n", pdu_tb_req_p->tb_size); - break; - } - pdu_p = NULL; - pdu_mem_p = NULL; - - //nb_bytes_to_transmit = nb_bytes_to_transmit - data_pdu_size; - nb_bytes_to_transmit = 0; // 1 PDU only - } - - RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); -} -//----------------------------------------------------------------------------- -void -rlc_um_segment_5 (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP) -{ - list_t pdus; - 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 = 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 TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" NO SEGMENTATION5 nb_bytes to transmit = %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - nb_bytes_to_transmit); -#endif - return; - } - - list_init (&pdus, NULL); // param string identifying the list is NULL - pdu_mem_p = NULL; - - RLC_UM_MUTEX_LOCK(&rlc_pP->lock_input_sdus, ctxt_pP, rlc_pP); - - while ((list_get_head(&rlc_pP->input_sdus)) && (nb_bytes_to_transmit > 0)) { -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT"nb_bytes_to_transmit %d BO %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - nb_bytes_to_transmit, - rlc_pP->buffer_occupancy); -#endif - - // pdu_p management - if (!pdu_mem_p) { - if (rlc_pP->input_sdus.nb_elements <= 1) { - max_li_overhead = 0; - } else { - 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; -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - data_pdu_size); -#endif - } else { - data_pdu_size = nb_bytes_to_transmit; -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - data_pdu_size); -#endif - } - - if (!(pdu_mem_p = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req), __func__))) { -#if TRACE_RLC_UM_SEGMENT - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" ERROR COULD NOT GET NEW PDU, EXIT\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); -#endif - RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); - return; - } - -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" get new PDU %d bytes\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - data_pdu_size); -#endif - pdu_remaining_size = data_pdu_size - 1; - pdu_p = (rlc_um_pdu_sn_5_t*) (&pdu_mem_p->data[sizeof(struct mac_tb_req)]); - pdu_tb_req_p = (struct mac_tb_req*) (pdu_mem_p->data); - - memset (pdu_mem_p->data, 0, sizeof (rlc_um_pdu_sn_5_t)+sizeof(struct mac_tb_req)); - li_length_in_bytes = 1; - } - - //---------------------------------------- - // compute how many SDUS can fill the PDU - //---------------------------------------- - continue_fill_pdu_with_sdu = 1; - num_fill_sdu = 0; - test_num_li = 0; - 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 ((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 - continue_fill_pdu_with_sdu = 0; - num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - } else if (sdu_mngt_p->sdu_remaining_size == test_pdu_remaining_size) { - // fi will indicate end of PDU is end of SDU, no need for LI - continue_fill_pdu_with_sdu = 0; - num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - } else if ((sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) == test_pdu_remaining_size ) { - // no LI - continue_fill_pdu_with_sdu = 0; - num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - pdu_remaining_size = pdu_remaining_size - (test_li_length_in_bytes ^ 3); - data_pdu_size -= (test_li_length_in_bytes ^ 3);//modifier pour duy - } else if ((sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) < test_pdu_remaining_size ) { - test_num_li += 1; - num_fill_sdu += 1; - test_pdu_remaining_size = test_pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)); - test_remaining_size_to_substract = test_li_length_in_bytes ^ 3; - test_remaining_num_li_to_substract = 1; - test_li_length_in_bytes = test_li_length_in_bytes ^ 3; - } else { -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" sdu_mngt_p->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p->sdu_remaining_size, - test_pdu_remaining_size, - test_li_length_in_bytes ^ 3); -#endif - // reduce the size of the PDU - continue_fill_pdu_with_sdu = 0; - num_fill_sdu += 1; - test_pdu_remaining_size = 0; - test_remaining_size_to_substract = 0; - test_remaining_num_li_to_substract = 0; - pdu_remaining_size = pdu_remaining_size - 1; - data_pdu_size -= 1;//modifier pour duy - } - - sdu_in_buffer = sdu_in_buffer->next; - } - - if (test_remaining_num_li_to_substract > 0) { - // there is a LI that is not necessary - test_num_li = test_num_li - 1; - pdu_remaining_size = pdu_remaining_size - test_remaining_size_to_substract; - } - - //---------------------------------------- - // Do the real filling of the pdu_p - //---------------------------------------- -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" data shift %d Bytes num_li %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - ((test_num_li*3) +1) >> 1, - test_num_li); -#endif - - data = ((char*)(&pdu_p->data[((test_num_li*3) +1) >> 1])); - e_li_p = (rlc_um_e_li_t*)(pdu_p->data); - continue_fill_pdu_with_sdu = 1; - li_length_in_bytes = 1; - fill_num_li = 0; - 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 *) (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 ((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 TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p, - sdu_mngt_p->sdu_remaining_size); -#endif - } else { -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes \n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p, - sdu_mngt_p->sdu_remaining_size, - sdu_mngt_p->sdu_size); -#endif - } - - data_sdu_p = (char*) &(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 TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling all remaining PDU with %d bytes\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_remaining_size); - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" pdu_mem_p %p pdu_p %p pdu_p->data %p data %p data_sdu_p %p pdu_remaining_size %d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_mem_p, - pdu_p, - pdu_p->data, - data, - data_sdu_p, - pdu_remaining_size); -#endif - - memcpy(data, data_sdu_p, pdu_remaining_size); - sdu_mngt_p->sdu_remaining_size = sdu_mngt_p->sdu_remaining_size - pdu_remaining_size; - sdu_mngt_p->sdu_segmented_size = sdu_mngt_p->sdu_segmented_size + pdu_remaining_size; - fi_last_byte_pdu_is_last_byte_sdu = 0; - // no LI - rlc_pP->buffer_occupancy -= pdu_remaining_size; - continue_fill_pdu_with_sdu = 0; - pdu_remaining_size = 0; - } else if (sdu_mngt_p->sdu_remaining_size == pdu_remaining_size) { -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Exactly Filling remaining PDU with %d remaining bytes of SDU\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - pdu_remaining_size); -#endif - memcpy(data, data_sdu_p, pdu_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, __func__); - 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 - continue_fill_pdu_with_sdu = 0; - pdu_remaining_size = 0; - } else if ((sdu_mngt_p->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling PDU with %d all remaining bytes of SDU\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p->sdu_remaining_size); -#endif - memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); - data = &data[sdu_mngt_p->sdu_remaining_size]; - li_length_in_bytes = li_length_in_bytes ^ 3; - fill_num_li += 1; - - if (li_length_in_bytes == 2) { - if (fill_num_li == test_num_li) { - //e_li_p->e1 = 0; - e_li_p->b1 = 0; - } else { - //e_li_p->e1 = 1; - e_li_p->b1 = 0x80; - } - - //e_li_p->li1 = sdu_mngt_p->sdu_remaining_size; - e_li_p->b1 = e_li_p->b1 | (sdu_mngt_p->sdu_remaining_size >> 4); - e_li_p->b2 = sdu_mngt_p->sdu_remaining_size << 4; -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" set e_li_p->b1=%02X set e_li_p->b2=%02X fill_num_li=%d test_num_li=%d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - e_li_p->b1, - e_li_p->b2, - fill_num_li, - test_num_li); -#endif - } else { - if (fill_num_li != test_num_li) { - //e_li_p->e2 = 1; - e_li_p->b2 = e_li_p->b2 | 0x08; - } - - //e_li_p->li2 = sdu_mngt_p->sdu_remaining_size; - e_li_p->b2 = e_li_p->b2 | (sdu_mngt_p->sdu_remaining_size >> 8); - e_li_p->b3 = sdu_mngt_p->sdu_remaining_size & 0xFF; -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" set e_li_p->b2=%02X set e_li_p->b3=%02X fill_num_li=%d test_num_li=%d\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - e_li_p->b2, - e_li_p->b3, - fill_num_li, - test_num_li); -#endif - 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; - sdu_in_buffer = list_remove_head(&rlc_pP->input_sdus); - free_mem_block (sdu_in_buffer, __func__); - sdu_in_buffer = list_get_head(&rlc_pP->input_sdus); - sdu_mngt_p = NULL; - - } else { - LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), - sdu_mngt_p->sdu_remaining_size, - pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); - //assert(1!=1); - memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); - // 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, __func__); - sdu_in_buffer = list_get_head(&rlc_pP->input_sdus); - sdu_mngt_p = NULL; - } - } - - // set framing info - if (fi_first_byte_pdu_is_first_byte_sdu) { - fi = 0; - } else { - fi = 2; - } - - if (!fi_last_byte_pdu_is_last_byte_sdu) { - fi = fi + 1; - } - - pdu_p->b1 = (fi << 6); //pdu_p->b1 | - - // set fist e bit - if (fill_num_li > 0) { - pdu_p->b1 = pdu_p->b1 | 0x20; - } - - pdu_p->b1 = pdu_p->b1 | (rlc_pP->vt_us & 0x1F); - rlc_pP->vt_us = rlc_pP->vt_us+1; - - pdu_tb_req_p->data_ptr = (unsigned char*)pdu_p; - pdu_tb_req_p->tb_size = data_pdu_size - pdu_remaining_size; - list_add_tail_eurecom (pdu_mem_p, &rlc_pP->pdus_to_mac_layer); -#if TRACE_RLC_PAYLOAD - rlc_util_print_hex_octets(RLC, (unsigned char*)pdu_mem_p->data, data_pdu_size); -#endif - //AssertFatal( pdu_tb_req_p->tb_size > 0 , "SEGMENT5: FINAL RLC UM PDU LENGTH %d", pdu_tb_req_p->tb_size); - if(pdu_tb_req_p->tb_size <= 0) { - LOG_E(RLC, "SEGMENT5: FINAL RLC UM PDU LENGTH %d\n", pdu_tb_req_p->tb_size); - break; - } - - pdu_p = NULL; - pdu_mem_p = NULL; - - //nb_bytes_to_transmit = nb_bytes_to_transmit - data_pdu_size; - nb_bytes_to_transmit = 0; // 1 PDU only - } - - RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); -} - diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.h deleted file mode 100644 index 0d52f1a89689c06c74a55e4111cb80a1b06a1739..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_um_segment.h -* \brief This file defines the prototypes of the functions dealing with the segmentation of PDCP SDUs. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -/** @defgroup _rlc_um_segment_impl_ RLC UM Segmentation Implementation -* @ingroup _rlc_um_impl_ -* @{ -*/ -# ifndef __RLC_UM_SEGMENT_PROTO_EXTERN_H__ -# define __RLC_UM_SEGMENT_PROTO_EXTERN_H__ -//----------------------------------------------------------------------------- -# include "rlc_um_entity.h" -# include "rlc_um_structs.h" -# include "rlc_um_constants.h" -# include "list.h" -//----------------------------------------------------------------------------- -/*! \fn void rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlcP) -* \brief Segmentation procedure with 10 bits sequence number, segment the first SDU in buffer and create a PDU of the size (nb_bytes_to_transmit) requested by MAC if possible and put it in the list "pdus_to_mac_layer". -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC UM protocol instance pointer. -*/ -void rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlcP); - - -/*! \fn void rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlcP) -* \brief Segmentation procedure with 5 bits sequence number, segment the first SDU in buffer and create a PDU of the size (nb_bytes_to_transmit) requested by MAC if possible and put it in the list "pdus_to_mac_layer". -* \param[in] ctxtP Running context. -* \param[in] rlcP RLC UM protocol instance pointer. -*/ -void rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlcP); -/** @} */ -# endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_structs.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_structs.h deleted file mode 100644 index 7ab9798a38d66a128079abe3142ddf3f960ffb04..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_structs.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_um_structs.h -* \brief This file defines structures used inside the RLC UM. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -# ifndef __RLC_UM_STRUCTS_H__ -# define __RLC_UM_STRUCTS_H__ - -# include "platform_types.h" -# include "list.h" -# include "rlc_um_constants.h" -# include "mac_primitives.h" -# include "rlc_primitives.h" -# include "mac_rlc_primitives.h" -//----------------------- -/** -* @addtogroup _rlc_um_impl_ -* @{ -*/ -/*! \struct rlc_um_tx_sdu_management_t -* \brief Structure containing SDU variables related to its segmentation and transmission. -*/ -typedef struct rlc_um_tx_sdu_management { - uint8_t *first_byte; /*!< \brief Pointer on SDU payload. */ - int32_t sdu_creation_time; /*!< \brief Time stamped with mac_xface->frame. */ - uint16_t sdu_remaining_size; /*!< \brief Remaining size in bytes to be filled in a PDU. */ - uint16_t sdu_test_remaining_size; - uint16_t sdu_segmented_size; /*!< \brief Bytes already segmented in a/several PDU(s). */ - uint16_t sdu_size; /*!< \brief SDU size in bytes. */ -} rlc_um_tx_sdu_management_t; -/** @} */ - -/** -* @addtogroup _rlc_um_segment_impl_ -* @{ -*/ -/*! \struct rlc_um_pdu_sn_5_t -* \brief Structure helping coding and decoding the first byte of a UMD PDU. -*/ -typedef struct rlc_um_pdu_sn_5 { - uint8_t b1; /*!< \brief 1st byte. */ - uint8_t data[3]; /*!< \brief Following bytes. */ -} __attribute__((__packed__)) rlc_um_pdu_sn_5_t ; - -/*! \struct rlc_um_pdu_sn_10_t -* \brief Structure helping coding and decoding the first 2 bytes of a UMD PDU. -*/ -typedef struct rlc_um_pdu_sn_10 { - uint8_t b1; /*!< \brief 1st byte. */ - uint8_t b2; /*!< \brief 2nd byte. */ - uint8_t data[2]; /*!< \brief Following bytes. */ -} __attribute__((__packed__)) rlc_um_pdu_sn_10_t ; - - -/*! \struct rlc_am_e_li_t -* \brief Structure helping coding and decoding LI and e bits in UMD PDUs. -*/ -typedef struct rlc_um_e_li { - uint8_t b1; /*!< \brief 1st byte. */ - uint8_t b2; /*!< \brief 2nd byte. */ - uint8_t b3; /*!< \brief 3rd byte. */ -} rlc_um_e_li_t; -/** @} */ -/** -* @addtogroup _rlc_um_segment_impl_ -* @{ -*/ -/*! \struct rlc_um_pdu_info_t -* \brief Structure for storing decoded informations from the header of a UMD PDU. -*/ -typedef struct rlc_um_pdu_info { - uint16_t free_bits:3; /*!< \brief unused bits in bitfield. */ - uint16_t fi:2; /*!< \brief Framing Info field. */ - uint16_t e:1; /*!< \brief Extension bit field. */ - uint16_t sn:10; /*!< \brief Sequence Number field. */ - uint16_t num_li; /*!< \brief Number of Length Indicators. */ - int16_t li_list[RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU]; /*!< \brief List of Length Indicators. */ - int16_t hidden_size; /*!< \brief Part of payload size in bytes that is not included in the sum of LI fields. */; - uint8_t* payload; /*!< \brief Pointer on PDU payload. */ - int16_t payload_size;/*!< \brief Size of payload in bytes. */ - int16_t header_size; /*!< \brief Size of header in bytes (including SO field and LI fields). */ -} rlc_um_pdu_info_t ; -/** @} */ - - -struct rlc_um_data_req_alloc { // alloc enought bytes for sdu mngt also - union { - struct rlc_um_data_req dummy1; - struct rlc_um_tx_sdu_management dummy2; - } dummy; -}; - -# endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c deleted file mode 100644 index cf77f9ec37f6992fa829a35ce2f5f5d035c362d1..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c +++ /dev/null @@ -1,1331 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_UM_MODULE -#define RLC_C -#define RLC_UM_TEST_C -#include <execinfo.h> -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include <string.h> -#include <assert.h> -#include <signal.h> -#include <sys/time.h> -//#include <curses.h> - -#include "platform_types.h" -//----------------------------------------------------------------------------- -#include "rlc.h" -#include "rlc_um.h" -#include "list.h" -#include "rlc_um_control_primitives.h" -#include "LAYER2/MAC/extern.h" - - -#define TEST1 -#define TEST2 -#define TEST3 -#define TEST4 -#define TEST5 - -#define INCREMENT_FRAME_YES 1 -#define INCREMENT_FRAME_NO 0 - -#define TEST_MAX_SEND_SDU 8192 -#define TARGET_MAX_RX_ERROR_RATE 10 -#define TARGET_MAX_TX_ERROR_RATE 10 -static int g_frame = 0; -static int g_error_on_phy = 0; -static int g_random_sdu; -static int g_random_nb_frames; - -static int g_random_tx_pdu_size; -static int g_random_rx_pdu_size; - -static int g_target_tx_error_rate; -static int g_target_rx_error_rate; - -static int g_tx_packets = 0; -static int g_dropped_tx_packets = 0; -static int g_rx_packets = 0; -static int g_dropped_rx_packets = 0; -static int g_drop_rx = 0; -static int g_drop_tx = 0; - -static int g_send_sdu_ids[TEST_MAX_SEND_SDU][2]; -static int g_send_id_write_index[2]; -static int g_send_id_read_index[2]; - -// time in frame numbers -#define MAX_TIME_DELAYED_PDU_DUE_TO_HARQ 256 -static struct mac_data_ind g_tx_delayed_indications[MAX_TIME_DELAYED_PDU_DUE_TO_HARQ]; -static struct mac_data_ind g_rx_delayed_indications[MAX_TIME_DELAYED_PDU_DUE_TO_HARQ]; - -static rlc_um_entity_t um_tx; -static rlc_um_entity_t um_rx; - -static int8_t *g_sdus[] = {"En dépit de son volontarisme affiché, le premier ministre est de plus en plus décrié pour son incompétence. La tension politique et dans l'opinion publique est encore montée d'un cran au Japon, sur fond d'inquiétantes nouvelles, avec du plutonium détecté dans le sol autour de la centrale de Fukushima. Le premier ministre Naoto Kan a solennellement déclaré que son gouvernement était «en état d'alerte maximum». Tout en reconnaissant que la situation restait «imprévisible». Ce volontarisme affiché par le premier ministre - que Nicolas Sarkozy rencontrera demain lors d'une visite au Japon - ne l'a pas empêché d'être la cible de violentes critiques de la part de parlementaires sur sa gestion de la crise. Attaqué sur le manque de transparence, il a assuré qu'il rendait publiques toutes les informations en sa possession. Un député de l'opposition, Yosuke Isozaki, a aussi reproché à Naoto Kan de ne pas avoir ordonné l'évacuation des populations dans la zone comprise entre 20 et 30 km autour de la centrale. «Peut-il y avoir quelque chose de plus irresponsable que cela ?», a-t-il lancé. Pour l'heure, la zone d'évacuation est limitée à un rayon de 20 km, seul le confinement étant recommandé pour les 10 km suivants. Sur ce sujet, les autorités japonaises ont été fragilisées mardi par les déclarations de Greenpeace, affirmant que ses experts avaient détecté une radioactivité dangereuse à 40 km de la centrale. L'organisation écologiste a appelé à une extension de la zone d'évacuation, exhortant Tokyo à «cesser de privilégier la politique aux dépens de la science». L'Agence japonaise de sûreté nucléaire a balayé ces critiques.", - - "La pâquerette (Bellis perennis) est une plante vivace des prés, des pelouses, des bords de chemins et des prairies, haute de dix à vingt centimètres, de la famille des Astéracées, dont les fleurs naissent sur des inflorescences appelées capitules : celles du pourtour, que l'on croit à tort être des pétales, appelées fleurs ligulées, parce qu'elles ont la forme d'une languette, ou demi-fleurons, sont des fleurs femelles, dont la couleur varie du blanc au rose plus ou moins prononcé ; celles du centre, jaunes, appelées fleurs tubuleuses, parce que leur corolle forme un tube, ou fleurons, sont hermaphrodites. Ainsi, contrairement à l'opinion populaire, ce qu'on appelle une « fleur » de pâquerette n'est en réalité pas « une » fleur mais un capitule portant des fleurs très nombreuses.Leurs fruits s'envolent grâce au vent et dégagent des odeurs qui attirent les insectes.Une variété muricole peut pousser sur des murs humides verticaux.Les pâquerettes sont des fleurs rustiques et très communes en Europe, sur les gazons, les prairies, les chemins et les zones d'herbe rase.Elles ont la particularité, comme certaines autres fleurs de plantes herbacées, de se fermer la nuit et de s'ouvrir le matin pour s'épanouir au soleil ; elles peuvent aussi se fermer pendant les averses, voire un peu avant, ce qui permet dans les campagnes de prédire la pluie légèrement à l'avance.", - - "La pâquerette", - " (Bellis perennis)", - " est une plante vivace des prés,", - " des pelouses,", - " des bords de chemins et des prairies,", - "haute de dix à ", - " vingt centimètres", - ", de la", - " famille des", - " Astéracées", - ", dont", - " les", - " fleurs", - " naissent", - " sur", - " des", - " inflorescences", - " appelées", - " capitules", - " : celles", - " du pourtour", - ", que l'on", - " croit à ", - " tort", - " être", - " des pétales", - ", appelées", - " fleurs ligulées", - ", parce qu'elles", - " ont la forme d'une languette, ou demi-fleurons, sont", - " des fleurs femelles,", - " dont la couleur varie du blanc au rose plus ou moins prononcé ; celles du centre, jaunes,", - " appelées ", - "fleurs tubuleuses", - ", parce que leur corolle forme un tube, ou fleurons, sont hermaphrodites." - }; - -#define RLC_2_PRINT_BUFFER_LEN 10000 -static char rlc_2_print_buffer[RLC_2_PRINT_BUFFER_LEN]; -//----------------------------------------------------------------------------- -void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char *dataP, unsigned long sizeP) -//----------------------------------------------------------------------------- -{ - unsigned long octet_index = 0; - unsigned long buffer_marker = 0; - unsigned char aindex; - - if (dataP == NULL) { - return; - } - - LOG_D(RLC, "------+-------------------------------------------------|\n"); - LOG_D(RLC, " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"); - LOG_D(RLC, "------+-------------------------------------------------|\n"); - - for (octet_index = 0; octet_index < sizeP; octet_index++) { - if ((octet_index % 16) == 0) { - if (octet_index != 0) { - buffer_marker+=snprintf(&rlc_2_print_buffer[buffer_marker], RLC_2_PRINT_BUFFER_LEN - buffer_marker, " |\n"); - LOG_D(RLC, "%s", rlc_2_print_buffer); - buffer_marker = 0; - } - - buffer_marker+=snprintf(&rlc_2_print_buffer[buffer_marker], RLC_2_PRINT_BUFFER_LEN - buffer_marker, - " %04lu |", octet_index); - } - - /* - * Print every single octet in hexadecimal form - */ - buffer_marker+=snprintf(&rlc_2_print_buffer[buffer_marker], RLC_2_PRINT_BUFFER_LEN - buffer_marker, " %02x", dataP[octet_index]); - /* - * Align newline and pipes according to the octets in groups of 2 - */ - } - - /* - * Append enough spaces and put final pipe - */ - for (aindex = octet_index; aindex < 16; ++aindex) { - buffer_marker+=snprintf(&rlc_2_print_buffer[buffer_marker], RLC_2_PRINT_BUFFER_LEN - buffer_marker, " "); - } - - // LOG_D(RLC, " "); - buffer_marker+=snprintf(&rlc_2_print_buffer[buffer_marker], RLC_2_PRINT_BUFFER_LEN - buffer_marker, " |\n"); - LOG_D(RLC, "%s",rlc_2_print_buffer); -} - -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_windows_10() -//----------------------------------------------------------------------------- -{ - rlc_um_entity_t um1; - rlc_um_entity_t um2; - unsigned int h,w, sn, result; - uint32_t timer_reordering = 2000; - uint32_t sn_field_length = 10; - uint32_t is_mXch = 0; // boolean, true if configured for MTCH or MCCH - rlc_um_init(&um1); - rlc_um_init(&um2); - rlc_um_set_debug_infos(&um1, g_frame, 0, 0, 0, 1, 1 /*LC-id = RAB-id*/); - rlc_um_set_debug_infos(&um2, g_frame, 1, 1, 1, 1, 1 /*LC-id = RAB-id*/); - rlc_um_configure(&um1, g_frame, timer_reordering, sn_field_length, sn_field_length, is_mXch); - rlc_um_configure(&um2, g_frame, timer_reordering, sn_field_length, sn_field_length, is_mXch); - - // RX window with vr_uh > vr_ur - for (h = 0; h < RLC_UM_SN_10_BITS_MODULO; h++) { - um1.vr_uh = h; - - for (w = 1; w < RLC_UM_WINDOW_SIZE_SN_10_BITS; w++) { - um1.vr_ur = (um1.vr_uh - w) & RLC_UM_SN_10_BITS_MASK; - - for (sn = ((um1.vr_uh - um1.rx_um_window_size) & RLC_UM_SN_10_BITS_MASK) ; sn != um1.vr_uh; sn = ((sn+1) & RLC_UM_SN_10_BITS_MASK)) { - assert(rlc_um_in_reordering_window(&um1, g_frame, sn) >= 0); - // returns -2 if lower_bound > sn - // returns -1 if higher_bound < sn - // returns 0 if lower_bound < sn < higher_bound - // returns 1 if lower_bound == sn - // returns 2 if higher_bound == sn - // returns 3 if higher_bound == sn == lower_bound - result = rlc_um_in_window(&um1, g_frame, (um1.vr_uh - um1.rx_um_window_size) & RLC_UM_SN_10_BITS_MASK, sn, um1.vr_uh); - assert((result < 2) && (result >=0)); - } - - for (sn = um1.vr_uh ; sn != ((um1.vr_uh - um1.rx_um_window_size) & RLC_UM_SN_10_BITS_MASK) ; sn = ((sn+1) & RLC_UM_SN_10_BITS_MASK)) { - // returns -2 if lower_bound > sn - // returns -1 if higher_bound < sn - // returns 0 if lower_bound < sn < higher_bound - // returns 1 if lower_bound == sn - // returns 2 if higher_bound == sn - // returns 3 if higher_bound == sn == lower_bound - assert(rlc_um_in_window(&um1, g_frame, (um1.vr_uh - um1.rx_um_window_size) & RLC_UM_SN_10_BITS_MASK, sn, (um1.vr_uh -1) & RLC_UM_SN_10_BITS_MASK) < 0); - assert(rlc_um_in_reordering_window(&um1, g_frame, sn) < 0); - } - } - } -} -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_windows_5() -//----------------------------------------------------------------------------- -{ - rlc_um_entity_t um1; - rlc_um_entity_t um2; - unsigned int h,w, sn, result; - uint32_t timer_reordering = 2000; - uint32_t sn_field_length = 5; - uint32_t is_mXch = 0; // boolean, true if configured for MTCH or MCCH - rlc_um_init(&um1); - rlc_um_init(&um2); - rlc_um_set_debug_infos(&um1, g_frame, 0, 0, 0, 1, 1 /* LC-id = DRB-id */); - rlc_um_set_debug_infos(&um2, g_frame, 1, 1, 1, 1, 1 /* LC-id = DRB-id */); - rlc_um_configure(&um1, g_frame, timer_reordering, sn_field_length, sn_field_length, is_mXch); - rlc_um_configure(&um2, g_frame, timer_reordering, sn_field_length, sn_field_length, is_mXch); - - // RX window with vr_uh > vr_ur - for (h = 0; h < RLC_UM_SN_5_BITS_MODULO; h++) { - um1.vr_uh = h; - - for (w = 1; w < RLC_UM_WINDOW_SIZE_SN_5_BITS; w++) { - um1.vr_ur = (um1.vr_uh - w) & RLC_UM_SN_5_BITS_MASK; - - for (sn = ((um1.vr_uh - um1.rx_um_window_size) & RLC_UM_SN_5_BITS_MASK) ; sn != um1.vr_uh; sn = ((sn+1) & RLC_UM_SN_5_BITS_MASK)) { - assert(rlc_um_in_reordering_window(&um1, g_frame, sn) >= 0); - // returns -2 if lower_bound > sn - // returns -1 if higher_bound < sn - // returns 0 if lower_bound < sn < higher_bound - // returns 1 if lower_bound == sn - // returns 2 if higher_bound == sn - // returns 3 if higher_bound == sn == lower_bound - result = rlc_um_in_window(&um1, g_frame, (um1.vr_uh - um1.rx_um_window_size) & RLC_UM_SN_5_BITS_MASK, sn, um1.vr_uh); - assert((result < 2) && (result >=0)); - } - - for (sn = um1.vr_uh ; sn != ((um1.vr_uh - um1.rx_um_window_size) & RLC_UM_SN_5_BITS_MASK) ; sn = ((sn+1) & RLC_UM_SN_5_BITS_MASK)) { - // returns -2 if lower_bound > sn - // returns -1 if higher_bound < sn - // returns 0 if lower_bound < sn < higher_bound - // returns 1 if lower_bound == sn - // returns 2 if higher_bound == sn - // returns 3 if higher_bound == sn == lower_bound - assert(rlc_um_in_window(&um1, g_frame, (um1.vr_uh - um1.rx_um_window_size) & RLC_UM_SN_5_BITS_MASK, sn, (um1.vr_uh -1) & RLC_UM_SN_5_BITS_MASK) < 0); - assert(rlc_um_in_reordering_window(&um1, g_frame, sn) < 0); - } - } - } -} -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_reset_sdus() -//----------------------------------------------------------------------------- -{ - int i, j; - - for (j = 0; j < 2; j++) { - for (i = 0; i < TEST_MAX_SEND_SDU; i++) { - g_send_sdu_ids[i][j]= -1; - } - - g_send_id_write_index[j] = 0; - g_send_id_read_index[j] = 0; - } -} -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_send_sdu(rlc_um_entity_t *um_txP, int sdu_indexP) -//----------------------------------------------------------------------------- -{ - mem_block_t *sdu; - sdu = get_free_mem_block (strlen(g_sdus[sdu_indexP]) + 1 + sizeof (struct rlc_um_data_req_alloc), __func__); - - if (sdu != NULL) { - // PROCESS OF COMPRESSION HERE: - printf("[FRAME %05d][RLC][MOD %02d][RB %02d] TX SDU %d %04d bytes\n",g_frame,um_txP->module_id, um_txP->rb_id, sdu_indexP, strlen(g_sdus[sdu_indexP]) + 1); - memset (sdu->data, 0, sizeof (struct rlc_um_data_req_alloc)); - strcpy (&sdu->data[sizeof (struct rlc_um_data_req_alloc)],g_sdus[sdu_indexP]); - ((struct rlc_um_data_req *) (sdu->data))->data_size = strlen(g_sdus[sdu_indexP])+ 1; - ((struct rlc_um_data_req *) (sdu->data))->data_offset = sizeof (struct rlc_um_data_req_alloc); - rlc_um_data_req(um_txP, g_frame, sdu); - g_send_sdu_ids[g_send_id_write_index[um_txP->rb_id]++][um_txP->rb_id] = sdu_indexP; - assert(g_send_id_write_index[um_txP->rb_id] < TEST_MAX_SEND_SDU); - } else { - printf("Out of memory error\n"); - // exit(-1); - } -} - -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_buffer_delayed_rx_mac_data_ind(struct mac_data_ind *data_indP, signed int time_delayedP) -//----------------------------------------------------------------------------- -{ - int frame_modulo; - mem_block_t *tb; - - if (time_delayedP <= 0) { - frame_modulo = g_frame % MAX_TIME_DELAYED_PDU_DUE_TO_HARQ; - } else { - frame_modulo = (g_frame + time_delayedP) % MAX_TIME_DELAYED_PDU_DUE_TO_HARQ; - } - - while (data_indP->data.nb_elements > 0) { - tb = list_remove_head (&data_indP->data); - - if (tb != NULL) { - if (time_delayedP < 0) { - list_add_head(tb, &g_rx_delayed_indications[frame_modulo].data); - } else { - list_add_tail_eurecom(tb, &g_rx_delayed_indications[frame_modulo].data); - } - - g_rx_delayed_indications[frame_modulo].no_tb += 1; - } - } - - assert(data_indP->data.head == NULL); -} -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_buffer_delayed_tx_mac_data_ind(struct mac_data_ind *data_indP, signed int time_delayedP) -//----------------------------------------------------------------------------- -{ - int frame_modulo; - mem_block_t *tb; - - if (time_delayedP <= 0) { - frame_modulo = g_frame % MAX_TIME_DELAYED_PDU_DUE_TO_HARQ; - } else { - frame_modulo = (g_frame + time_delayedP) % MAX_TIME_DELAYED_PDU_DUE_TO_HARQ; - } - - while (data_indP->data.nb_elements > 0) { - tb = list_remove_head (&data_indP->data); - - if (tb != NULL) { - if (time_delayedP < 0) { - list_add_head(tb, &g_rx_delayed_indications[frame_modulo].data); - } else { - list_add_tail_eurecom(tb, &g_rx_delayed_indications[frame_modulo].data); - } - - g_rx_delayed_indications[frame_modulo].no_tb += 1; - } - } - - assert(data_indP->data.head == NULL); -} - -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_mac_rlc_loop (struct mac_data_ind *data_indP, struct mac_data_req *data_requestP, int *drop_countP, int *tx_packetsP, - int *dropped_tx_packetsP) -//----------------------------------------------------------------------------- -{ - mem_block_t *tb_src; - mem_block_t *tb_dst; - unsigned int tb_size; - data_indP->no_tb = 0; - - while (data_requestP->data.nb_elements > 0) { - tb_src = list_remove_head (&data_requestP->data); - - if (tb_src != NULL) { - tb_size = ((struct mac_tb_req *) (tb_src->data))->tb_size_in_bits >> 3; - printf("[RLC-LOOP] FOUND TB SIZE IN BITS %d IN BYTES %u sizeof (mac_rlc_max_rx_header_size_t) %d\n", - ((struct mac_tb_req *) (tb_src->data))->tb_size_in_bits, - tb_size, sizeof (mac_rlc_max_rx_header_size_t)); - *tx_packetsP = *tx_packetsP + 1; - - if (*drop_countP == 0) { - tb_dst = get_free_mem_block(sizeof (mac_rlc_max_rx_header_size_t) + tb_size, __func__); - - if (tb_dst != NULL) { - memset(tb_dst->data, 0, sizeof (mac_rlc_max_rx_header_size_t) + tb_size); - //printf("[RLC-LOOP] Testing tb_dst (1)\n"); - check_free_mem_block(tb_dst, __func__); - tb_dst->next = NULL; - ((struct mac_tb_ind *) (tb_dst->data))->first_bit = 0; - ((struct mac_tb_ind *) (tb_dst->data))->data_ptr = &tb_dst->data[sizeof (mac_rlc_max_rx_header_size_t)]; - ((struct mac_tb_ind *) (tb_dst->data))->size = tb_size; - ((struct mac_tb_ind *) (tb_dst->data))->error_indication = 0; - memcpy(((struct mac_tb_ind *) (tb_dst->data))->data_ptr, - &((struct mac_tb_req *) (tb_src->data))->data_ptr[0], - tb_size); - list_add_tail_eurecom(tb_dst, &data_indP->data); - data_indP->no_tb += 1; - //printf("[RLC-LOOP] Testing tb_dst (2)\n"); - check_free_mem_block(tb_dst, __func__); - } else { - printf("Out of memory error\n"); - // exit(-1); - } - } else { - printf("[RLC-LOOP] DROPPING 1 TB\n"); - *drop_countP = *drop_countP - 1; - *dropped_tx_packetsP = *dropped_tx_packetsP + 1; - } - - //printf("[RLC-LOOP] Testing tb_src\n"); - check_free_mem_block(tb_src, __func__); - free_mem_block(tb_src, __func__); - - if (data_indP->no_tb > 0) { - printf("[RLC-LOOP] Exchange %d TBs\n",data_indP->no_tb); - } - } - } -} -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_exchange_pdus(rlc_um_entity_t *um_txP, - rlc_um_entity_t *um_rxP, - uint16_t bytes_txP, - uint16_t bytes_rxP) -//----------------------------------------------------------------------------- -{ - struct mac_data_req data_request_tx; - struct mac_data_req data_request_rx; - struct mac_data_ind data_ind_tx; - struct mac_data_ind data_ind_rx; - struct mac_status_ind tx_status; - struct mac_status_resp mac_rlc_status_resp_tx; - struct mac_status_resp mac_rlc_status_resp_rx; - memset(&data_request_tx, 0, sizeof(struct mac_data_req)); - memset(&data_request_rx, 0, sizeof(struct mac_data_req)); - memset(&data_ind_tx, 0, sizeof(struct mac_data_ind)); - memset(&data_ind_rx, 0, sizeof(struct mac_data_ind)); - memset(&tx_status, 0, sizeof(struct mac_status_ind)); - memset(&mac_rlc_status_resp_tx, 0, sizeof(struct mac_status_resp)); - memset(&mac_rlc_status_resp_rx, 0, sizeof(struct mac_status_resp)); - mac_rlc_status_resp_tx = rlc_um_mac_status_indication(um_txP, g_frame, 1, bytes_txP, tx_status,ENB_FLAG_YES); - data_request_tx = rlc_um_mac_data_request(um_txP, g_frame); - mac_rlc_status_resp_rx = rlc_um_mac_status_indication(um_rxP, g_frame, 0, bytes_rxP, tx_status,ENB_FLAG_YES); - data_request_rx = rlc_um_mac_data_request(um_rxP, g_frame); - rlc_um_v9_3_0_test_mac_rlc_loop(&data_ind_rx, &data_request_tx, &g_drop_tx, &g_tx_packets, &g_dropped_tx_packets); - rlc_um_v9_3_0_test_mac_rlc_loop(&data_ind_tx, &data_request_rx, &g_drop_rx, &g_rx_packets, &g_dropped_rx_packets); - rlc_um_mac_data_indication(um_rxP, g_frame, um_rxP->is_enb, data_ind_rx); - rlc_um_mac_data_indication(um_txP, g_frame, um_txP->is_enb, data_ind_tx); - g_frame += 1; - //check_mem_area(); - //display_mem_load(); -} -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_exchange_delayed_pdus(rlc_um_entity_t *um_txP, - rlc_um_entity_t *um_rxP, - uint16_t bytes_txP, - uint16_t bytes_rxP, - signed int time_tx_delayedP, // if -1 added to the head of current frame tx mac data ind if any - // if 0 added to the tail of current frame tx mac data ind if any - // if > 0 added to the tail of frame+time_tx_delayedP mac data ind if any - signed int time_rx_delayedP, // if -1 added to the head of current frame rx mac data ind if any - // if 0 added to the tail of current frame rx mac data ind if any - // if > 0 added to the tail of frame+time_rx_delayedP mac data ind if any - int is_frame_incrementedP) -//----------------------------------------------------------------------------- -{ - struct mac_data_req data_request_tx; - struct mac_data_req data_request_rx; - struct mac_data_ind data_ind_tx; - struct mac_data_ind data_ind_rx; - struct mac_status_ind tx_status; - struct mac_status_resp mac_rlc_status_resp_tx; - struct mac_status_resp mac_rlc_status_resp_rx; - int frame_modulo = g_frame % MAX_TIME_DELAYED_PDU_DUE_TO_HARQ; - memset(&data_request_tx, 0, sizeof(struct mac_data_req)); - memset(&data_request_rx, 0, sizeof(struct mac_data_req)); - memset(&data_ind_tx, 0, sizeof(struct mac_data_ind)); - memset(&data_ind_rx, 0, sizeof(struct mac_data_ind)); - memset(&tx_status, 0, sizeof(struct mac_status_ind)); - memset(&mac_rlc_status_resp_tx, 0, sizeof(struct mac_status_resp)); - memset(&mac_rlc_status_resp_rx, 0, sizeof(struct mac_status_resp)); - mac_rlc_status_resp_tx = rlc_um_mac_status_indication(um_txP, g_frame, 1, bytes_txP, tx_status,ENB_FLAG_YES); - data_request_tx = rlc_um_mac_data_request(um_txP, g_frame); - mac_rlc_status_resp_rx = rlc_um_mac_status_indication(um_rxP, g_frame, 0, bytes_rxP, tx_status,ENB_FLAG_YES); - data_request_rx = rlc_um_mac_data_request(um_rxP, g_frame); - rlc_um_v9_3_0_test_mac_rlc_loop(&data_ind_rx, &data_request_tx, &g_drop_tx, &g_tx_packets, &g_dropped_tx_packets); - rlc_um_v9_3_0_test_mac_rlc_loop(&data_ind_tx, &data_request_rx, &g_drop_rx, &g_rx_packets, &g_dropped_rx_packets); - rlc_um_v9_3_0_buffer_delayed_rx_mac_data_ind(&data_ind_rx, time_tx_delayedP); - rlc_um_v9_3_0_buffer_delayed_tx_mac_data_ind(&data_ind_tx, time_rx_delayedP); - rlc_um_mac_data_indication(um_rxP, g_frame, um_rxP->is_enb, g_rx_delayed_indications[frame_modulo]); - memset(&g_rx_delayed_indications[frame_modulo], 0, sizeof(struct mac_data_ind)); - rlc_um_mac_data_indication(um_txP, g_frame, um_txP->is_enb, g_tx_delayed_indications[frame_modulo]); - memset(&g_tx_delayed_indications[frame_modulo], 0, sizeof(struct mac_data_ind)); - - if (is_frame_incrementedP) { - g_frame += 1; - } -} - -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_data_conf(module_id_t module_idP, rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP) -//----------------------------------------------------------------------------- -{ - if (statusP == RLC_SDU_CONFIRM_YES) { - printf("[FRAME %05d][RLC][MOD %02d][RB %02d] CONFIRM SEND SDU MUI %05d\n",g_frame,module_idP, rb_idP, muiP); - } else { - printf("[FRAME %05d][RLC][MOD %02d][RB %02d] CONFIRM LOST SDU MUI %05d\n",g_frame,module_idP, rb_idP, muiP); - } -} -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_data_ind (module_id_t module_idP, rb_id_t rb_idP, sdu_size_t sizeP, mem_block_t *sduP) -//----------------------------------------------------------------------------- -{ - int i; - - if (g_error_on_phy == 0) { - for (i = 0; i < 37; i++) { - if (strcmp(g_sdus[i], sduP->data) == 0) { - printf("[FRAME %05d][RLC][MOD %02d][RB %02d] RX SDU %d %04d bytes\n",g_frame,module_idP, rb_idP, i, sizeP); - assert(TEST_MAX_SEND_SDU > g_send_id_read_index[rb_idP]); - assert(g_send_id_write_index[rb_idP^1] > g_send_id_read_index[rb_idP]); - - if (g_send_sdu_ids[g_send_id_read_index[rb_idP]][rb_idP^1] != i) { - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP]-2, - g_send_sdu_ids[g_send_id_read_index[rb_idP]-2][rb_idP^1]); - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP]-1, - g_send_sdu_ids[g_send_id_read_index[rb_idP]-1][rb_idP^1]); - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_sdu_ids[%d] = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP], - g_send_sdu_ids[g_send_id_read_index[rb_idP]][rb_idP^1]); - printf("[FRAME %05d][RLC][MOD %d][RB %d][DATA-IND] g_send_id_read_index = %d sdu sent = %d\n",g_frame,module_idP, rb_idP, g_send_id_read_index[rb_idP], i); - } - - assert(g_send_sdu_ids[g_send_id_read_index[rb_idP]][rb_idP^1] == i); - g_send_id_read_index[rb_idP] += 1; - free_mem_block(sduP, __func__); - return; - } - } - - printf("[FRAME %05d][RLC][MOD %d][RB %d] RX UNKNOWN SDU %04d bytes\n",g_frame,module_idP, rb_idP, sizeP); - free_mem_block(sduP, __func__); - assert(1==2); - } else { - for (i = 0; i < 37; i++) { - if (strcmp(g_sdus[i], sduP->data) == 0) { - printf("[FRAME %05d][RLC][MOD %02d][RB %02d] RX SDU %d %04d bytes\n",g_frame,module_idP, rb_idP, i, sizeP); - assert(TEST_MAX_SEND_SDU > g_send_id_read_index[rb_idP]); - g_send_id_read_index[rb_idP] += 1; - free_mem_block(sduP, __func__); - return; - } - } - - printf("[FRAME %05d][RLC][MOD %d][RB %d] RX UNKNOWN SDU %04d bytes\n",g_frame,module_idP, rb_idP, sizeP); - free_mem_block(sduP, __func__); - return; - } -} -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_reordering(uint32_t sn_field_lengthP) -//----------------------------------------------------------------------------- -{ - rlc_um_info_t um_info; - int i,j,r; - um_info.timer_reordering = (32 * sn_field_lengthP * sn_field_lengthP)/100; - um_info.sn_field_length = sn_field_lengthP; - um_info.is_mXch = 0; - srand (0); - config_req_rlc_um (&um_tx, 0,0,0, &um_info, 0, SIGNALLING_RADIO_BEARER, SIGNALLING_RADIO_BEARER /*LC-id = DRB-id*/); - config_req_rlc_um (&um_rx, 0,1,1, &um_info, 1, SIGNALLING_RADIO_BEARER, SIGNALLING_RADIO_BEARER /*LC-id = DRB-id*/); - rlc_um_display_rx_window(&um_tx); - rlc_um_display_rx_window(&um_rx); - srand (0); - // BIG SDU SMALL PDUS NO ERRORS - rlc_um_v9_3_0_test_reset_sdus(); - - for (i = 0; i < 128; i++) { - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 3, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 3, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 3, 200, um_info.timer_reordering - 5, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 4, 200, 7, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 5, 200, 5, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 6, 200, 3, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 7, 200, 1, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 8, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 9, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 10, 200, 7, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 11, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 12, 200, 5, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 13, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 14, 200, 3, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 15, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 16, 200, 1, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 17, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 18, 200, 3, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 19, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 20, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 21, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 22, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 23, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 24, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 25, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 26, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 27, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 28, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 29, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 2000, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 2000, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 2000, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 2000, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 2000, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 2000, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 2000, 200, 0, 0, INCREMENT_FRAME_YES); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n\n\n"); - } - - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test_reordering 3: END OF TEST BIG SDU, SMALL PDUs\n\n\n\n"); - rlc_um_v9_3_0_test_reset_sdus(); - - for (j = 0; j < 16; j++) { - //i = getchar(); - rlc_um_v9_3_0_test_reset_sdus(); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - - for (i = 0; i < 32; i++) { - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 3, 200, 0, 0, INCREMENT_FRAME_YES); - } - - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 2000, 200, 0, 0, INCREMENT_FRAME_YES); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 3, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 3, 200, 0, 0, INCREMENT_FRAME_YES); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 3, 200, um_info.timer_reordering + 5, 0, INCREMENT_FRAME_YES); - - for (i = 0; i < 600; i++) { - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 3, 200, 0, 0, INCREMENT_FRAME_YES); - } - - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 2000, 200, 0, 0, INCREMENT_FRAME_YES); - printf("g_send_id_read_index[1]=%d g_send_id_write_index[0]=%d Loop %d (1)\n", g_send_id_read_index[1], g_send_id_write_index[0], j); - assert (g_send_id_read_index[1] != g_send_id_write_index[0]); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 3, 200, 0, 0, INCREMENT_FRAME_YES); - - for (i = 0; i < 600; i++) { - if ((i % 32) == 0) { - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 3, 200, um_info.timer_reordering + 5, 0, INCREMENT_FRAME_YES); - } else { - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 3, 200, 0, 0, INCREMENT_FRAME_YES); - } - } - - rlc_um_v9_3_0_test_exchange_delayed_pdus(&um_tx, &um_rx, 2000, 200, 0, 0, INCREMENT_FRAME_YES); - printf("g_send_id_read_index[1]=%d g_send_id_write_index[0]=%d Loop %d (2)\n", g_send_id_read_index[1], g_send_id_write_index[0], j); - assert (g_send_id_read_index[1] != g_send_id_write_index[0]); - } - - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test_reordering 4: END OF TEST BIG SDU, SMALL PDUs\n\n\n\n"); -} -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_tx_rx_10(void) -//----------------------------------------------------------------------------- -{ - rlc_um_info_t um_info; - int i,j,r; - um_info.timer_reordering = 32; - um_info.sn_field_length = 10; - um_info.is_mXch = 0; - srand (0); - config_req_rlc_um (&um_tx, 0,0,0, &um_info, 0, SIGNALLING_RADIO_BEARER, SIGNALLING_RADIO_BEARER /*LC-id = DRB-id*/); - config_req_rlc_um (&um_rx, 0,1,1, &um_info, 1, SIGNALLING_RADIO_BEARER, SIGNALLING_RADIO_BEARER /*LC-id = DRB-id*/); - rlc_um_display_rx_window(&um_tx); - rlc_um_display_rx_window(&um_rx); -#ifdef TEST1 - srand (0); - rlc_um_v9_3_0_test_reset_sdus(); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 2); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 2); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 2); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 3); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 4); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 5); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 6); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 1000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 1000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 1000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 1000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 1000, 200); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 1: END OF SIMPLE TEST SEVERAL SDUs IN PDU\n\n\n\n"); - sleep(2); - rlc_um_v9_3_0_test_reset_sdus(); - - // RANDOM TESTS - for (i = g_send_id_write_index[0]; g_send_id_write_index[0] < TEST_MAX_SEND_SDU-12; i++) { - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 2); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 2); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 2); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 3); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 4); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 5); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 6); - - for (i = 0; i < 50; i++) { - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 200, 200); - } - - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - } - - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 1: END OF TEST SEVERAL SDUs IN PDU\n\n\n\n"); - sleep(2); -#endif -#ifdef TEST2 - srand (0); - rlc_um_v9_3_0_test_reset_sdus(); - // BIG SDU SMALL PDUS NO ERRORS - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 3, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 3, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 3, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 4, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 5, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 6, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 7, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 9, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 10, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 11, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 12, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 13, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 14, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 15, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 16, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 17, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 18, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 19, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 20, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 21, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 22, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 23, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 24, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 25, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 26, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 27, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 28, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 29, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 2000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 2000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 2000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 2000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 30, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 31, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 32, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 33, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 34, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 35, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 36, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 37, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 38, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 39, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 40, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 41, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 42, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 43, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 44, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 45, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 46, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 47, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 48, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 49, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 50, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 51, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 52, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 53, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 54, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 55, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 56, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 57, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 58, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 59, 200); - - //rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 60, 200); if uncomment: error because too many segments of SDU - for (i = 0; i < 24; i++) { - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 2000, 200); - } - - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 2: END OF TEST BIG SDU SMALL PDUs\n\n\n\n"); -#endif - - for (r = 0; r < 32; r++) { - //for (r = 0; r < 1024; r++) { - srand (r); -#ifdef TEST3 - g_error_on_phy = 0; - g_tx_packets = 0; - g_rx_packets = 0; - rlc_um_v9_3_0_test_reset_sdus(); - - // RANDOM TESTS - for (i = g_send_id_write_index[0]; g_send_id_write_index[0] < TEST_MAX_SEND_SDU-1; i++) { - printf("UM.TX SDU %d\n", um_tx.nb_sdu); - - if (um_tx.nb_sdu < (um_tx.size_input_sdus_buffer - 2)) { - g_random_sdu = rand() % 37; - rlc_um_v9_3_0_test_send_sdu(&um_tx, g_random_sdu); - } - - g_random_nb_frames = (rand() % 10) + 1; - - //g_random_nb_frames = 1; - for (j = 0; j < g_random_nb_frames; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - } - - for (j = 0; j < 400; j++) { - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 500, 500); - } - - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 3: END OF TEST RANDOM (SEED=%d ) TX ONLY :\n\n\n\n", - r); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); -#endif -#ifdef TEST4 - g_error_on_phy = 0; - g_tx_packets = 0; - g_rx_packets = 0; - rlc_um_v9_3_0_test_reset_sdus(); - - for (i = g_send_id_write_index[0]; g_send_id_write_index[0] < TEST_MAX_SEND_SDU-1; i++) { - if (um_tx.nb_sdu < (um_rx.size_input_sdus_buffer - 2)) { - g_random_sdu = rand() % 37; - rlc_um_v9_3_0_test_send_sdu(&um_tx, g_random_sdu); - - if (um_rx.nb_sdu < (um_rx.size_input_sdus_buffer - 2)) { - g_random_sdu = rand() % 37; - rlc_um_v9_3_0_test_send_sdu(&um_rx, g_random_sdu); - } else { - i = i-1; - } - } else { - if (um_rx.nb_sdu < (um_rx.size_input_sdus_buffer - 2)) { - g_random_sdu = rand() % 37; - rlc_um_v9_3_0_test_send_sdu(&um_rx, g_random_sdu); - } else { - i = i-1; - } - } - - g_random_nb_frames = rand() % 4; - - for (j = 0; j < g_random_nb_frames; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - } - - for (j = 0; j < 100; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 4: END OF TEST RANDOM (SEED=%d) TX RX:\n\n\n\n",r); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - assert (g_send_id_read_index[0] == g_send_id_write_index[1]); -#endif - } - -#ifdef TEST5 - rlc_um_display_rx_window(&um_tx); - rlc_um_display_rx_window(&um_rx); - - for (r = 0; r < 1024; r++) { - srand (r); - g_error_on_phy = 1; - - for (g_target_tx_error_rate = 0; g_target_tx_error_rate < TARGET_MAX_TX_ERROR_RATE; g_target_tx_error_rate++) { - for (g_target_rx_error_rate = 0; g_target_rx_error_rate < TARGET_MAX_RX_ERROR_RATE; g_target_rx_error_rate++) { - g_tx_packets = 0; - g_dropped_tx_packets = 0; - g_rx_packets = 0; - g_dropped_rx_packets = 0; - rlc_um_v9_3_0_test_reset_sdus(); - - for (i = g_send_id_write_index[0]; g_send_id_write_index[0] < TEST_MAX_SEND_SDU-1; i++) { - g_random_sdu = rand() % 37; - rlc_um_v9_3_0_test_send_sdu(&um_tx, g_random_sdu); - g_random_sdu = rand() % 37; - //rlc_um_v9_3_0_test_send_sdu(&um_rx, g_random_sdu); - g_random_nb_frames = rand() % 4; - - for (j = 0; j < g_random_nb_frames; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - - //rlc_um_display_rx_window(&um_tx); - rlc_um_display_rx_window(&um_rx); - int dropped = (rand() % 3); - - if ((dropped == 0) && (g_tx_packets > 0)) { - if ((((g_dropped_tx_packets + 1)*100) / g_tx_packets) <= g_target_tx_error_rate) { - g_drop_tx = 1; - } - } - - dropped = (rand() % 3); - - if ((dropped == 0) && (g_rx_packets > 0)) { - if ((((g_dropped_rx_packets + 1)*100) / g_rx_packets) <= g_target_rx_error_rate) { - g_drop_rx = 1; - } - } - } - - for (j = 0; j < 100; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 5: END OF TEST RANDOM (SEED=%d BLER TX=%d BLER RX=%d ) TX RX WITH ERRORS ON PHY LAYER:\n\n\n\n", - r, g_target_tx_error_rate, g_target_rx_error_rate); - //assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - //assert (g_send_id_read_index[0] == g_send_id_write_index[1]); - printf("REAL BLER TX=%d (TARGET=%d) BLER RX=%d (TARGET=%d) \n", - (g_tx_packets >0)?(g_dropped_tx_packets*100)/g_tx_packets:0, - g_target_tx_error_rate, - (g_rx_packets >0)?(g_dropped_rx_packets*100)/g_rx_packets:0, - g_target_rx_error_rate); - } - } - - g_drop_tx = 0; - g_drop_rx = 0; - g_tx_packets = 0; - g_dropped_tx_packets = 0; - g_rx_packets = 0; - g_dropped_rx_packets = 0; - rlc_um_v9_3_0_test_reset_sdus(); - - for (j = 0; j < 100; j++) { - rlc_um_v9_3_0_test_send_sdu(&um_rx, 1); - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - } - - g_error_on_phy = 0; -#endif -} -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_tx_rx_5(void) -//----------------------------------------------------------------------------- -{ - rlc_um_info_t um_info; - int i,j,r; - um_info.timer_reordering = 32; - um_info.sn_field_length = 5; - um_info.is_mXch = 0; - srand (0); - config_req_rlc_um (&um_tx, 0,0,0, &um_info, 0, SIGNALLING_RADIO_BEARER, SIGNALLING_RADIO_BEARER /*LC-id = DRB-id*/); - config_req_rlc_um (&um_rx, 0,1,1, &um_info, 1, SIGNALLING_RADIO_BEARER, SIGNALLING_RADIO_BEARER /*LC-id = DRB-id*/); - rlc_um_display_rx_window(&um_tx); - rlc_um_display_rx_window(&um_rx); -#ifdef TEST1 - srand (0); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test_5 1: START OF SIMPLE TEST SEVERAL SDUs IN PDU\n\n\n\n"); - rlc_um_v9_3_0_test_reset_sdus(); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 2); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 2); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 2); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 3); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 4); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 5); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 6); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 1000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 1000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 1000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 1000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 1000, 200); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test_5 1: END OF SIMPLE TEST SEVERAL SDUs IN PDU\n\n\n\n"); - sleep(2); - rlc_um_v9_3_0_test_reset_sdus(); - - // RANDOM TESTS - for (i = g_send_id_write_index[0]; g_send_id_write_index[0] < TEST_MAX_SEND_SDU-12; i++) { - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 2); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 2); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 2); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 3); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 4); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 5); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 6); - - for (i = 0; i < 50; i++) { - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 400, 200); - } - - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - } - - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 1: END OF TEST SEVERAL SDUs IN PDU\n\n\n\n"); - sleep(2); -#endif -#ifdef TEST2 - srand (0); - rlc_um_v9_3_0_test_reset_sdus(); - // BIG SDU SMALL PDUS NO ERRORS - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 3, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 3, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 3, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 4, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 5, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 6, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 7, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 8, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 9, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 10, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 11, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 12, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 13, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 14, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 15, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 16, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 17, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 18, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 19, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 20, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 21, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 22, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 23, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 24, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 25, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 2000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 2000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 2000, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 2000, 200); - rlc_um_v9_3_0_test_send_sdu(&um_tx, 1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 26, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 27, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 28, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 29, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 30, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 31, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 32, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 33, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 34, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 35, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 36, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 37, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 38, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 39, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 40, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 41, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 42, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 43, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 44, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 45, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 46, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 47, 200); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 48, 200); - - //rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 60, 200); if uncomment: error because too many segments of SDU - for (i = 0; i < 24; i++) { - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 2000, 200); - } - - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 2: END OF TEST BIG SDU SMALL PDUs\n\n\n\n"); -#endif - - for (r = 0; r < 32; r++) { - //for (r = 0; r < 1024; r++) { - srand (r); -#ifdef TEST3 - g_error_on_phy = 0; - g_tx_packets = 0; - g_rx_packets = 0; - rlc_um_v9_3_0_test_reset_sdus(); - - // RANDOM TESTS - for (i = g_send_id_write_index[0]; g_send_id_write_index[0] < TEST_MAX_SEND_SDU-1; i++) { - printf("UM.TX SDU %d\n", um_tx.nb_sdu); - - if (um_tx.nb_sdu < (um_tx.size_input_sdus_buffer - 2)) { - g_random_sdu = rand() % 37; - rlc_um_v9_3_0_test_send_sdu(&um_tx, g_random_sdu); - } - - g_random_nb_frames = (rand() % 10) + 1; - - //g_random_nb_frames = 1; - for (j = 0; j < g_random_nb_frames; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - } - - for (j = 0; j < 400; j++) { - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, 500, 500); - } - - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 3: END OF TEST RANDOM (SEED=%d ) TX ONLY :\n\n\n\n",r); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); -#endif -#ifdef TEST4 - g_error_on_phy = 0; - g_tx_packets = 0; - g_rx_packets = 0; - rlc_um_v9_3_0_test_reset_sdus(); - - for (i = g_send_id_write_index[0]; g_send_id_write_index[0] < TEST_MAX_SEND_SDU-1; i++) { - if (um_tx.nb_sdu < (um_rx.size_input_sdus_buffer - 2)) { - g_random_sdu = rand() % 37; - rlc_um_v9_3_0_test_send_sdu(&um_tx, g_random_sdu); - - if (um_rx.nb_sdu < (um_rx.size_input_sdus_buffer - 2)) { - g_random_sdu = rand() % 37; - rlc_um_v9_3_0_test_send_sdu(&um_rx, g_random_sdu); - } else { - i = i-1; - } - } else { - if (um_rx.nb_sdu < (um_rx.size_input_sdus_buffer - 2)) { - g_random_sdu = rand() % 37; - rlc_um_v9_3_0_test_send_sdu(&um_rx, g_random_sdu); - } else { - i = i-1; - } - } - - g_random_nb_frames = rand() % 4; - - for (j = 0; j < g_random_nb_frames; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - } - - for (j = 0; j < 100; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 4: END OF TEST RANDOM (SEED=%d) TX RX:\n\n\n\n",r); - assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - assert (g_send_id_read_index[0] == g_send_id_write_index[1]); -#endif - } - -#ifdef TEST5 - rlc_um_display_rx_window(&um_tx); - rlc_um_display_rx_window(&um_rx); - - for (r = 0; r < 1024; r++) { - srand (r); - g_error_on_phy = 1; - - for (g_target_tx_error_rate = 0; g_target_tx_error_rate < TARGET_MAX_TX_ERROR_RATE; g_target_tx_error_rate++) { - for (g_target_rx_error_rate = 0; g_target_rx_error_rate < TARGET_MAX_RX_ERROR_RATE; g_target_rx_error_rate++) { - g_tx_packets = 0; - g_dropped_tx_packets = 0; - g_rx_packets = 0; - g_dropped_rx_packets = 0; - rlc_um_v9_3_0_test_reset_sdus(); - - for (i = g_send_id_write_index[0]; g_send_id_write_index[0] < TEST_MAX_SEND_SDU-1; i++) { - g_random_sdu = rand() % 37; - rlc_um_v9_3_0_test_send_sdu(&um_tx, g_random_sdu); - g_random_sdu = rand() % 37; - //rlc_um_v9_3_0_test_send_sdu(&um_rx, g_random_sdu); - g_random_nb_frames = rand() % 4; - - for (j = 0; j < g_random_nb_frames; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - - //rlc_um_display_rx_window(&um_tx); - rlc_um_display_rx_window(&um_rx); - int dropped = (rand() % 3); - - if ((dropped == 0) && (g_tx_packets > 0)) { - if ((((g_dropped_tx_packets + 1)*100) / g_tx_packets) <= g_target_tx_error_rate) { - g_drop_tx = 1; - } - } - - dropped = (rand() % 3); - - if ((dropped == 0) && (g_rx_packets > 0)) { - if ((((g_dropped_rx_packets + 1)*100) / g_rx_packets) <= g_target_rx_error_rate) { - g_drop_rx = 1; - } - } - } - - for (j = 0; j < 100; j++) { - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - - printf("\n\n\n\n\n\n-----------------------------------------------------------------------------------------rlc_um_v9_3_0_test 5: END OF TEST RANDOM (SEED=%d BLER TX=%d BLER RX=%d ) TX RX WITH ERRORS ON PHY LAYER:\n\n\n\n", - r, g_target_tx_error_rate, g_target_rx_error_rate); - //assert (g_send_id_read_index[1] == g_send_id_write_index[0]); - //assert (g_send_id_read_index[0] == g_send_id_write_index[1]); - printf("REAL BLER TX=%d (TARGET=%d) BLER RX=%d (TARGET=%d) \n", - (g_tx_packets >0)?(g_dropped_tx_packets*100)/g_tx_packets:0, - g_target_tx_error_rate, - (g_rx_packets >0)?(g_dropped_rx_packets*100)/g_rx_packets:0, - g_target_rx_error_rate); - } - } - - g_drop_tx = 0; - g_drop_rx = 0; - g_tx_packets = 0; - g_dropped_tx_packets = 0; - g_rx_packets = 0; - g_dropped_rx_packets = 0; - rlc_um_v9_3_0_test_reset_sdus(); - - for (j = 0; j < 100; j++) { - rlc_um_v9_3_0_test_send_sdu(&um_rx, 1); - g_random_tx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - g_random_rx_pdu_size = (rand() % RLC_SDU_MAX_SIZE) / ((rand () % 4)+1); - rlc_um_v9_3_0_test_exchange_pdus(&um_tx, &um_rx, g_random_tx_pdu_size, g_random_rx_pdu_size); - } - } - - g_error_on_phy = 0; -#endif -} - -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test_print_trace (void) -//----------------------------------------------------------------------------- -{ - void *array[100]; - size_t size; - char **strings; - size_t i; - size = backtrace (array, 100); - strings = backtrace_symbols (array, size); - printf ("Obtained %lu stack frames.\n", (unsigned long)size); - - for (i = 0; i < size; i++) { - printf ("%s\n", strings[i]); - } - - free (strings); -} -//----------------------------------------------------------------------------- -void rlc_um_v9_3_0_test(void) -//----------------------------------------------------------------------------- -{ - pool_buffer_init(); - set_comp_log(RLC, LOG_TRACE, LOG_MED, 1); - // tested OK - rlc_um_v9_3_0_test_reordering(10); - rlc_um_v9_3_0_test_tx_rx_10(); - // tested OK - rlc_um_v9_3_0_test_windows_10(); - rlc_um_v9_3_0_test_tx_rx_5(); - rlc_um_v9_3_0_test_windows_5(); - rlc_um_v9_3_0_test_reordering(5); - printf("rlc_um_v9_3_0_test: END OF TESTS\n"); - exit(0); -} diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.h deleted file mode 100644 index bfde1b31f35f286ae8d928011363468a059ffa0e..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -# ifndef __RLC_UM_TEST_H__ -# define __RLC_UM_TEST_H__ - -void rlc_um_v9_3_0_test_windows_5(void); -void rlc_um_v9_3_0_test_windows_10(void); -void rlc_um_v9_3_0_test_data_conf(module_id_t module_idP, rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP); -void rlc_um_v9_3_0_test_send_sdu(rlc_um_entity_t *um_txP, int sdu_indexP); -void rlc_um_v9_3_0_test_exchange_pdus(rlc_um_entity_t *um_txP,rlc_um_entity_t *um_RxP, uint16_t bytes_txP,uint16_t bytes_rxP); -void rlc_um_v9_3_0_test_exchange_delayed_pdus(rlc_um_entity_t *um_txP, rlc_um_entity_t *um_rxP, uint16_t bytes_txP, uint16_t bytes_rxP, signed int time_tx_delayedP, - signed int time_rx_delayedP, int is_frame_incrementedP); -void rlc_um_v9_3_0_buffer_delayed_rx_mac_data_ind(struct mac_data_ind* data_ind_rxP, signed int time_tx_delayedP); -void rlc_um_v9_3_0_test_mac_rlc_loop (struct mac_data_ind *data_indP, struct mac_data_req *data_requestP, int* drop_countP, int *tx_packetsP, int* dropped_tx_packetsP); -void rlc_um_v9_3_0_test_data_ind (module_id_t module_idP, rb_id_t rb_idP, sdu_size_t sizeP, - mem_block_t *sduP); -void rlc_um_v9_3_0_test_tx_rx_10(void); -void rlc_um_v9_3_0_test_tx_rx_5(void); -void rlc_um_v9_3_0_test_print_trace (void); -void rlc_um_v9_3_0_test(void); -# endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_very_simple_test.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_very_simple_test.c deleted file mode 100644 index 91985e4800d96f88f651c9d648af5eac35db0587..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_very_simple_test.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#define RLC_UM_MODULE -#define RLC_UM_VERY_SIMPLE_TEST_C -#include <string.h> -//#include "rtos_header.h" -#include "platform_types.h" - -#include "list.h" -#include "rlc_um.h" -#include "rlc.h" -#include "rlc_primitives.h" -#include "mac_primitives.h" -#include "LAYER2/MAC/extern.h" -#include "rlc_um_very_simple_test.h" - - - -//----------------------------------------------------------------------------- -void -rlc_um_test_send_sdu (rlc_um_entity_t* rlcP, uint32_t frame, unsigned int sdu_typeP) -{ - //----------------------------------------------------------------------------- - mem_block_t *sdu_mem; - - switch (sdu_typeP) { - case RLC_UM_TEST_SDU_TYPE_TCPIP: - sdu_mem = get_free_mem_block (strlen(tcip_sdu)+ 1 + sizeof (struct rlc_um_data_req_alloc), __func__); - - if (sdu_mem != NULL) { - memset (sdu_mem->data, 0, sizeof (struct rlc_um_data_req_alloc)); - ((struct rlc_um_data_req*)(sdu_mem->data))->data_size = strlen(tcip_sdu)+ 1; - ((struct rlc_um_data_req*)(sdu_mem->data))->data_offset = 0; - ((struct rlc_um_data_req*)(sdu_mem->data))->use_special_li = sizeof (struct rlc_um_data_req_alloc) - sizeof (struct rlc_um_data_req); - strcpy (&sdu_mem->data[sizeof (struct rlc_um_data_req_alloc)], tcip_sdu); - sdu_mem->data[sizeof (struct rlc_um_data_req_alloc)+ strlen(tcip_sdu)+1] = 0; - rlc_um_data_req (rlcP, frame, sdu_mem); - } - - break; - - case RLC_UM_TEST_SDU_TYPE_VOIP: - sdu_mem = get_free_mem_block (strlen(voip_sdu)+ 1 + sizeof (struct rlc_um_data_req_alloc), __func__); - - if (sdu_mem != NULL) { - memset (sdu_mem->data, 0, sizeof (struct rlc_um_data_req_alloc)); - ((struct rlc_um_data_req*)(sdu_mem->data))->data_size = strlen(voip_sdu)+ 1; - ((struct rlc_um_data_req*)(sdu_mem->data))->data_offset = sizeof (struct rlc_um_data_req_alloc) - sizeof (struct rlc_um_data_req); - ((struct rlc_um_data_req*)(sdu_mem->data))->use_special_li = 0; - strcpy (&sdu_mem->data[sizeof (struct rlc_um_data_req_alloc)], voip_sdu); - sdu_mem->data[sizeof (struct rlc_um_data_req_alloc)+ strlen(voip_sdu)+1] = 0; - rlc_um_data_req (rlcP, frame, sdu_mem); - } - - break; - - case RLC_UM_TEST_SDU_TYPE_SMALL: - sdu_mem = get_free_mem_block (strlen(very_small_sdu)+ 1 + sizeof (struct rlc_um_data_req_alloc), __func__); - - if (sdu_mem != NULL) { - memset (sdu_mem->data, 0, sizeof (struct rlc_um_data_req_alloc)); - ((struct rlc_um_data_req*)(sdu_mem->data))->data_size = strlen(very_small_sdu)+ 1; - ((struct rlc_um_data_req*)(sdu_mem->data))->data_offset = sizeof (struct rlc_um_data_req_alloc) - sizeof (struct rlc_um_data_req); - ((struct rlc_um_data_req*)(sdu_mem->data))->use_special_li = 0; - strcpy (&sdu_mem->data[sizeof (struct rlc_um_data_req_alloc)], very_small_sdu); - sdu_mem->data[sizeof (struct rlc_um_data_req_alloc)+ strlen(very_small_sdu)+1] = 0; - rlc_um_data_req (rlcP, frame, sdu_mem); - } - - break; - - default: - ; - } -} diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_very_simple_test.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_very_simple_test.h deleted file mode 100644 index b762a4fdb45f23feee8f3cf83c77bb08cd1647d1..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_very_simple_test.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_um_very_simple_test.h -* \brief This file defines the prototypes of the functions dealing with the sending of self generated packet for very basic test or debug of RLC or lower layers. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -# ifndef __RLC_UM_VERY_SIMPLE_TEST_H__ -# define __RLC_UM_VERY_SIMPLE_TEST_H__ -//----------------------------------------------------------------------------- -# include "rlc_um_entity.h" -# include "mem_block.h" -# include "rlc_um_structs.h" -# include "rlc_um_constants.h" -//----------------------------------------------------------------------------- -#define RLC_UM_TEST_SDU_TYPE_TCPIP 0 -#define RLC_UM_TEST_SDU_TYPE_VOIP 1 -#define RLC_UM_TEST_SDU_TYPE_SMALL 2 - -#define tcip_sdu "NOS TESTS MONTRENT QUE LE NOUVEAU TOSHIBA MK7559GSXP, UN DISQUE DUR DE 750 GO FONCTIONNANT AVEC DES SECTEURS DE 4 KO, EST AU MOINS AUSSI RAPIDE QUE SON PRÉDÉCESSEUR, LE MK6465GSX 640 GO, DANS TOUS LES BENCHMARKS THÉORIQUES. SES PERFORMANCES EN E/S ET SON TEMPS D’ACCÈS SONT COMPARABLES ET SON DÉBIT RÉEL EST MÊME NETTEMENT PLUS ÉLEVÉ. SES RÉSULTATS SOUS PCMARK VANTAGE, PAR CONTRE, SONT QUELQUE PEU MOINS BONS. DANS CE CAS, LEQUEL CHOISIR ? LES SCORES OBTENUS DANS LES TESTS THÉORIQUES NOUS CONFIRMENT QUE LE NOUVEAU MODÈLE SE COMPORTE CONVENABLEMENT « MALGRÉ » SES SECTEURS DE 4 KO ET QUE LA RAISON DU LÉGER RECUL DE SES PERFORMANCES SOUS PCMARK VANTAGE SE TROUVE AILLEURS. L’ALIGNEMENT DES SECTEURS N’EST PAS NON PLUS EN CAUSE, ÉTANT DONNÉ QUE WINDOWS VISTA (NOTRE OS DE TEST) ET WINDOWS 7 EN TIENNENT COMPTE LORS DE LA CRÉATION DES PARTITIONS — CE QUE NOUS AVONS BIEN ENTENDU VÉRIFIÉ INDÉPENDAMMENT.IL NOUS EST TOUTEFOIS IMPOSSIBLE DE CONTRÔLER L’EXÉCUTION ET L’ORGANISATION DE L’ÉCRITURE DES DONNÉES. PCMARK VANTAGE N’A EN EFFET JAMAIS ÉTÉ OPTIMISÉ POUR L’ÉCRITURE DE BLOCS DE DONNÉES DE GRANDE TAILLE ; DANS LA VIE RÉELLE, SI VOUS ÉCRIVEZ SURTOUT DE GROS FICHIERS, LE NOUVEAU DISQUE DUR DE 750 GO VA S’AVÉRER PLUS RAPIDE QUE LE 640 GO ET SURTOUT QUE LES RÉSULTATS ENREGISTRÉS DANS NOTRE BENCHMARK PCMARK, CAR SES SECTEURS DE 4 KO SERONT TOUJOURS PLUS PETITS QUE LES DONNÉES À ÉCRIRE. LE PROBLÈME EST QU’AUSSI LONGTEMPS QUE LES APPLICATIONS CONTINUERONT À EFFECTUER DES DEMANDES D’ÉCRITURE EN MODE 512 OCTETS" - -#define voip_sdu "Nos tests montrent que le nouveau Toshiba MK7559GSXP, un disque dur de 750 Go" -#define very_small_sdu "NoS tEsTs MoNtReNt" - -void rlc_um_test_send_sdu (rlc_um_entity_t* rlcP, uint32_t frame, unsigned int sdu_typeP); -# endif diff --git a/openair2/LAYER2/RLC/mac_primitives.h b/openair2/LAYER2/RLC/mac_primitives.h deleted file mode 100644 index 4690bba42e5b91f4721d727b38d41da928e0c55a..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/mac_primitives.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c deleted file mode 100644 index b18b67198f8f3566aac7c363e617b5199448482d..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/rlc.c +++ /dev/null @@ -1,683 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/* - rlc.c - ------------------- - AUTHOR : Lionel GAUTHIER - COMPANY : EURECOM - EMAIL : Lionel.Gauthier at eurecom dot fr -*/ -#define RLC_C -#include "rlc.h" -#include "mem_block.h" -#include "../MAC/mac_extern.h" -#include "LAYER2/RLC/UM_v9.3.0/rlc_um.h" -#include "common/utils/LOG/log.h" -#include "UTIL/OCG/OCG_vars.h" -#include "common/utils/LOG/vcd_signal_dumper.h" -#include "common/openairinterface5g_limits.h" -#include "assertions.h" -#include <rlc.h> - -#include "common/ran_context.h" -extern RAN_CONTEXT_t RC; - -extern bool pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_idP, - const sdu_size_t sdu_buffer_sizeP, - mem_block_t *const sdu_buffer_pP); - -#define DEBUG_RLC_PDCP_INTERFACE 1 -//#define TRACE_RLC_PAYLOAD 1 -#define DEBUG_RLC_DATA_REQ 1 -void (*rlc_rrc_data_conf)( - const protocol_ctxt_t *const ctxtP, - const rb_id_t rb_idP, - const mui_t muiP, - const rlc_tx_status_t statusP) __attribute__ ((aligned(32))); - -void (*rlc_rrc_data_ind)( - const protocol_ctxt_t *const ctxtP, - const rb_id_t rb_idP, - const sdu_size_t sdu_sizeP, - const uint8_t *const sduP) __attribute__ ((aligned(32))); - -logical_chan_id_t rlc_mbms_rbid2lcid_ue [MAX_MOBILES_PER_ENB][NB_RB_MBMS_MAX]; /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ -logical_chan_id_t rlc_mbms_rbid2lcid_eNB[MAX_eNB][NB_RB_MBMS_MAX]; /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ -rlc_mbms_id_t rlc_mbms_lcid2service_session_id_ue[MAX_MOBILES_PER_ENB][RLC_MAX_MBMS_LC]; // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h -rlc_mbms_id_t rlc_mbms_lcid2service_session_id_eNB[MAX_eNB][RLC_MAX_MBMS_LC]; // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h -hash_table_t *rlc_coll_p __attribute__ ((aligned(32))); - - -logical_chan_id_t rlc_mbms_rbid2lcid_ue [MAX_MOBILES_PER_ENB][NB_RB_MBMS_MAX]; /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ -logical_chan_id_t rlc_mbms_rbid2lcid_eNB[MAX_eNB][NB_RB_MBMS_MAX]; /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ -//----------------------------------------------------------------------------- -void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char *dataP, const signed long sizeP) -//----------------------------------------------------------------------------- -{ - unsigned long octet_index = 0; - - if (dataP == NULL) { - return; - } - - LOG_T(componentP, "+-----+-------------------------------------------------+\n"); - LOG_T(componentP, "| | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"); - LOG_T(componentP, "+-----+-------------------------------------------------+\n"); - - for (octet_index = 0; octet_index < sizeP; octet_index++) { - if ((octet_index % 16) == 0) { - if (octet_index != 0) { - LOG_T(componentP, " |\n"); - } - - LOG_T(componentP, " %04lu |", octet_index); - } - - /* - * Print every single octet in hexadecimal form - */ - LOG_T(componentP, " %02x", dataP[octet_index]); - /* - * Align newline and pipes according to the octets in groups of 2 - */ - } - - /* - * Append enough spaces and put final pipe - */ - unsigned char index; - - for (index = octet_index; index < 16; ++index) { - LOG_T(componentP, " "); - } - - LOG_T(componentP, " |\n"); -} - -//----------------------------------------------------------------------------- -rlc_op_status_t rlc_stat_req ( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const rb_id_t rb_idP, - unsigned int *stat_rlc_mode, - unsigned int *stat_tx_pdcp_sdu, - unsigned int *stat_tx_pdcp_bytes, - unsigned int *stat_tx_pdcp_sdu_discarded, - unsigned int *stat_tx_pdcp_bytes_discarded, - unsigned int *stat_tx_data_pdu, - unsigned int *stat_tx_data_bytes, - unsigned int *stat_tx_retransmit_pdu_by_status, - unsigned int *stat_tx_retransmit_bytes_by_status, - unsigned int *stat_tx_retransmit_pdu, - unsigned int *stat_tx_retransmit_bytes, - unsigned int *stat_tx_control_pdu, - unsigned int *stat_tx_control_bytes, - unsigned int *stat_rx_pdcp_sdu, - unsigned int *stat_rx_pdcp_bytes, - unsigned int *stat_rx_data_pdus_duplicate, - unsigned int *stat_rx_data_bytes_duplicate, - unsigned int *stat_rx_data_pdu, - unsigned int *stat_rx_data_bytes, - unsigned int *stat_rx_data_pdu_dropped, - unsigned int *stat_rx_data_bytes_dropped, - unsigned int *stat_rx_data_pdu_out_of_window, - unsigned int *stat_rx_data_bytes_out_of_window, - unsigned int *stat_rx_control_pdu, - unsigned int *stat_rx_control_bytes, - unsigned int *stat_timer_reordering_timed_out, - unsigned int *stat_timer_poll_retransmit_timed_out, - unsigned int *stat_timer_status_prohibit_timed_out) { - //----------------------------------------------------------------------------- - rlc_mode_t rlc_mode = RLC_MODE_NONE; - rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - - //AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); - if(rb_idP >= NB_RB_MAX) { - LOG_E(RLC, "RB id is too high (%ld/%d)!\n", rb_idP, NB_RB_MAX); - return RLC_OP_STATUS_BAD_PARAMETER; - } - - key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - if (h_rc == HASH_TABLE_OK) { - rlc_mode = rlc_union_p->mode; - } - - *stat_rlc_mode = rlc_mode; - - switch (rlc_mode) { - case RLC_MODE_NONE: - *stat_tx_pdcp_sdu = 0; - *stat_tx_pdcp_bytes = 0; - *stat_tx_pdcp_sdu_discarded = 0; - *stat_tx_pdcp_bytes_discarded = 0; - *stat_tx_data_pdu = 0; - *stat_tx_data_bytes = 0; - *stat_tx_retransmit_pdu_by_status = 0; - *stat_tx_retransmit_bytes_by_status = 0; - *stat_tx_retransmit_pdu = 0; - *stat_tx_retransmit_bytes = 0; - *stat_tx_control_pdu = 0; - *stat_tx_control_bytes = 0; - *stat_rx_pdcp_sdu = 0; - *stat_rx_pdcp_bytes = 0; - *stat_rx_data_pdus_duplicate = 0; - *stat_rx_data_bytes_duplicate = 0; - *stat_rx_data_pdu = 0; - *stat_rx_data_bytes = 0; - *stat_rx_data_pdu_dropped = 0; - *stat_rx_data_bytes_dropped = 0; - *stat_rx_data_pdu_out_of_window = 0; - *stat_rx_data_bytes_out_of_window = 0; - *stat_rx_control_pdu = 0; - *stat_rx_control_bytes = 0; - *stat_timer_reordering_timed_out = 0; - *stat_timer_poll_retransmit_timed_out = 0; - *stat_timer_status_prohibit_timed_out = 0; - return RLC_OP_STATUS_BAD_PARAMETER; - break; - - case RLC_MODE_AM: - rlc_am_stat_req(ctxt_pP, - &rlc_union_p->rlc.am, - stat_tx_pdcp_sdu, - stat_tx_pdcp_bytes, - stat_tx_pdcp_sdu_discarded, - stat_tx_pdcp_bytes_discarded, - stat_tx_data_pdu, - stat_tx_data_bytes, - stat_tx_retransmit_pdu_by_status, - stat_tx_retransmit_bytes_by_status, - stat_tx_retransmit_pdu, - stat_tx_retransmit_bytes, - stat_tx_control_pdu, - stat_tx_control_bytes, - stat_rx_pdcp_sdu, - stat_rx_pdcp_bytes, - stat_rx_data_pdus_duplicate, - stat_rx_data_bytes_duplicate, - stat_rx_data_pdu, - stat_rx_data_bytes, - stat_rx_data_pdu_dropped, - stat_rx_data_bytes_dropped, - stat_rx_data_pdu_out_of_window, - stat_rx_data_bytes_out_of_window, - stat_rx_control_pdu, - stat_rx_control_bytes, - stat_timer_reordering_timed_out, - stat_timer_poll_retransmit_timed_out, - stat_timer_status_prohibit_timed_out); - return RLC_OP_STATUS_OK; - break; - - case RLC_MODE_UM: - *stat_tx_retransmit_pdu_by_status = 0; - *stat_tx_retransmit_bytes_by_status = 0; - *stat_tx_retransmit_pdu = 0; - *stat_tx_retransmit_bytes = 0; - *stat_tx_control_pdu = 0; - *stat_tx_control_bytes = 0; - *stat_rx_data_pdu_dropped = 0; - *stat_rx_data_bytes_dropped = 0; - *stat_rx_data_pdu_out_of_window = 0; - *stat_rx_data_bytes_out_of_window = 0; - *stat_timer_poll_retransmit_timed_out = 0; - *stat_timer_status_prohibit_timed_out = 0; - rlc_um_stat_req (&rlc_union_p->rlc.um, - stat_tx_pdcp_sdu, - stat_tx_pdcp_bytes, - stat_tx_pdcp_sdu_discarded, - stat_tx_pdcp_bytes_discarded, - stat_tx_data_pdu, - stat_tx_data_bytes, - stat_rx_pdcp_sdu, - stat_rx_pdcp_bytes, - stat_rx_data_pdus_duplicate, - stat_rx_data_bytes_duplicate, - stat_rx_data_pdu, - stat_rx_data_bytes, - stat_rx_data_pdu_dropped, - stat_rx_data_bytes_dropped, - stat_rx_data_pdu_out_of_window, - stat_rx_data_bytes_out_of_window, - stat_timer_reordering_timed_out); - return RLC_OP_STATUS_OK; - break; - - case RLC_MODE_TM: - *stat_tx_pdcp_sdu = 0; - *stat_tx_pdcp_bytes = 0; - *stat_tx_pdcp_sdu_discarded = 0; - *stat_tx_pdcp_bytes_discarded = 0; - *stat_tx_data_pdu = 0; - *stat_tx_data_bytes = 0; - *stat_tx_retransmit_pdu_by_status = 0; - *stat_tx_retransmit_bytes_by_status = 0; - *stat_tx_retransmit_pdu = 0; - *stat_tx_retransmit_bytes = 0; - *stat_tx_control_pdu = 0; - *stat_tx_control_bytes = 0; - *stat_rx_pdcp_sdu = 0; - *stat_rx_pdcp_bytes = 0; - *stat_rx_data_pdus_duplicate = 0; - *stat_rx_data_bytes_duplicate = 0; - *stat_rx_data_pdu = 0; - *stat_rx_data_bytes = 0; - *stat_rx_data_pdu_dropped = 0; - *stat_rx_data_bytes_dropped = 0; - *stat_rx_data_pdu_out_of_window = 0; - *stat_rx_data_bytes_out_of_window = 0; - *stat_rx_control_pdu = 0; - *stat_rx_control_bytes = 0; - *stat_timer_reordering_timed_out = 0; - *stat_timer_poll_retransmit_timed_out = 0; - *stat_timer_status_prohibit_timed_out = 0; - return RLC_OP_STATUS_BAD_PARAMETER; - break; - - default: - *stat_tx_pdcp_sdu = 0; - *stat_tx_pdcp_bytes = 0; - *stat_tx_pdcp_sdu_discarded = 0; - *stat_tx_pdcp_bytes_discarded = 0; - *stat_tx_data_pdu = 0; - *stat_tx_data_bytes = 0; - *stat_tx_retransmit_pdu_by_status = 0; - *stat_tx_retransmit_bytes_by_status = 0; - *stat_tx_retransmit_pdu = 0; - *stat_tx_retransmit_bytes = 0; - *stat_tx_control_pdu = 0; - *stat_tx_control_bytes = 0; - *stat_rx_pdcp_sdu = 0; - *stat_rx_pdcp_bytes = 0; - *stat_rx_data_pdus_duplicate = 0; - *stat_rx_data_bytes_duplicate = 0; - *stat_rx_data_pdu = 0; - *stat_rx_data_bytes = 0; - *stat_rx_data_pdu_dropped = 0; - *stat_rx_data_bytes_dropped = 0; - *stat_rx_data_pdu_out_of_window = 0; - *stat_rx_data_bytes_out_of_window = 0; - *stat_rx_control_pdu = 0; - *stat_rx_control_bytes = 0; - *stat_timer_poll_retransmit_timed_out = 0; - *stat_timer_status_prohibit_timed_out = 0; - return RLC_OP_STATUS_BAD_PARAMETER; - } -} - -//----------------------------------------------------------------------------- -rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_idP, - const mui_t muiP, - confirm_t confirmP, - sdu_size_t sdu_sizeP, - mem_block_t *sdu_pP, - const uint32_t *const sourceL2Id, - const uint32_t *const destinationL2Id - ) { - //----------------------------------------------------------------------------- - mem_block_t *new_sdu_p = NULL; - rlc_mode_t rlc_mode = RLC_MODE_NONE; - rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - rlc_mbms_id_t *mbms_id_p = NULL; - logical_chan_id_t log_ch_id = 0; -#ifdef DEBUG_RLC_DATA_REQ - LOG_D(RLC,PROTOCOL_CTXT_FMT"rlc_data_req: rb_id %ld (MAX %d), muip %d, confirmP %d, sdu_sizeP %d, sdu_pP %p\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_idP, - NB_RAB_MAX, - muiP, - confirmP, - sdu_sizeP, - sdu_pP); -#endif -#if T_TRACER - - if (ctxt_pP->enb_flag) - T(T_ENB_RLC_DL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_sizeP)); - -#endif - - if (MBMS_flagP) { - //AssertFatal (rb_idP < NB_RB_MBMS_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MBMS_MAX); - if(rb_idP >= NB_RB_MBMS_MAX) { - LOG_E(RLC, "RB id is too high (%ld/%d)!\n", rb_idP, NB_RB_MBMS_MAX); - return RLC_OP_STATUS_BAD_PARAMETER; - } - } else { - //AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); - if(rb_idP >= NB_RB_MAX) { - LOG_E(RLC, "RB id is too high (%ld/%d)!\n", rb_idP, NB_RB_MAX); - return RLC_OP_STATUS_BAD_PARAMETER; - } - } - - //DevAssert(sdu_pP != NULL); - if(sdu_pP == NULL) { - LOG_E(RLC, "sdu_pP == NULL\n"); - return RLC_OP_STATUS_BAD_PARAMETER; - } - - //DevCheck(sdu_sizeP > 0, sdu_sizeP, 0, 0); - if(sdu_sizeP <= 0) { - LOG_E(RLC, "sdu_sizeP %d, file %s, line %d\n", sdu_sizeP, __FILE__,__LINE__); - return RLC_OP_STATUS_BAD_PARAMETER; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_IN); - - if (MBMS_flagP == true) { - if (ctxt_pP->enb_flag) { - log_ch_id = rlc_mbms_enb_get_lcid_by_rb_id(ctxt_pP->module_id,rb_idP); - mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][log_ch_id]; - } else { - log_ch_id = rlc_mbms_ue_get_lcid_by_rb_id(ctxt_pP->rnti,rb_idP); - mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ctxt_pP->rnti][log_ch_id]; - } - - key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_id_p->service_id, mbms_id_p->session_id); - } else if (sourceL2Id && destinationL2Id) { - LOG_D (RLC, "RLC_COLL_KEY_VALUE: ctxt_pP->module_id: %d, ctxt_pP->rnti: %d, ctxt_pP->enb_flag: %d, rb_idP:%ld, srb_flagP: %d \n \n", ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, - srb_flagP); - key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); - //Thinh's line originally uncommented - //key = RLC_COLL_KEY_SOURCE_DEST_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, *sourceL2Id, *destinationL2Id, srb_flagP); - //key_lcid = RLC_COLL_KEY_LCID_SOURCE_DEST_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, chan_idP, *sourceL2Id, *destinationL2Id, srb_flagP); - } else { - LOG_D (RLC, "RLC_COLL_KEY_VALUE: ctxt_pP->module_id: %d, ctxt_pP->rnti: %d, ctxt_pP->enb_flag: %d, rb_idP:%ld, srb_flagP: %d \n \n", ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, - srb_flagP); - key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); - } - - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - if (h_rc == HASH_TABLE_OK) { - rlc_mode = rlc_union_p->mode; - } else { - rlc_mode = RLC_MODE_NONE; - //AssertFatal (0 , "RLC not configured key %ju\n", key); - LOG_E(RLC, "not configured key %lu\n", key); - return RLC_OP_STATUS_OUT_OF_RESSOURCES; - } - - if (MBMS_flagP == 0) { - LOG_D(RLC, PROTOCOL_CTXT_FMT"[RB %ld] Display of rlc_data_req:\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_idP); -#if defined(TRACE_RLC_PAYLOAD) - rlc_util_print_hex_octets(RLC, (unsigned char *)sdu_pP->data, sdu_sizeP); -#endif -#ifdef DEBUG_RLC_DATA_REQ - LOG_D(RLC,"RLC_TYPE : %d\n", rlc_mode); -#endif - - switch (rlc_mode) { - case RLC_MODE_NONE: - free_mem_block(sdu_pP, __func__); - LOG_E(RLC, PROTOCOL_CTXT_FMT" Received RLC_MODE_NONE as rlc_type for rb_id %ld\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_idP); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); - return RLC_OP_STATUS_BAD_PARAMETER; - - case RLC_MODE_AM: -#ifdef DEBUG_RLC_DATA_REQ - LOG_D(RLC,"RLC_MODE_AM\n"); -#endif - new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_am_data_req_alloc), __func__); - - if (new_sdu_p != NULL) { - // PROCESS OF COMPRESSION HERE: - memset (new_sdu_p->data, 0, sizeof (struct rlc_am_data_req_alloc)); - memcpy (&new_sdu_p->data[sizeof (struct rlc_am_data_req_alloc)], &sdu_pP->data[0], sdu_sizeP); - ((struct rlc_am_data_req *) (new_sdu_p->data))->data_size = sdu_sizeP; - ((struct rlc_am_data_req *) (new_sdu_p->data))->conf = confirmP; - ((struct rlc_am_data_req *) (new_sdu_p->data))->mui = muiP; - ((struct rlc_am_data_req *) (new_sdu_p->data))->data_offset = sizeof (struct rlc_am_data_req_alloc); - free_mem_block(sdu_pP, __func__); - rlc_am_data_req(ctxt_pP, &rlc_union_p->rlc.am, new_sdu_p); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); - return RLC_OP_STATUS_OK; - } else { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); - free_mem_block(sdu_pP, __func__); - return RLC_OP_STATUS_INTERNAL_ERROR; - } - - break; - - case RLC_MODE_UM: - - /* TODO: this is a hack, needs better solution. Let's not use too - * much memory and store at maximum 5 millions bytes. - */ - /* look for HACK_RLC_UM_LIMIT for others places related to the hack. Please do not remove this comment. */ - if (rlc_um_get_buffer_occupancy(&rlc_union_p->rlc.um) > 5000000) { - free_mem_block(sdu_pP, __func__); - return RLC_OP_STATUS_OUT_OF_RESSOURCES; - } - - new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_um_data_req_alloc), __func__); - - if (new_sdu_p != NULL) { - // PROCESS OF COMPRESSION HERE: - memset (new_sdu_p->data, 0, sizeof (struct rlc_um_data_req_alloc)); - memcpy (&new_sdu_p->data[sizeof (struct rlc_um_data_req_alloc)], &sdu_pP->data[0], sdu_sizeP); - ((struct rlc_um_data_req *) (new_sdu_p->data))->data_size = sdu_sizeP; - ((struct rlc_um_data_req *) (new_sdu_p->data))->data_offset = sizeof (struct rlc_um_data_req_alloc); - free_mem_block(sdu_pP, __func__); - rlc_um_data_req(ctxt_pP, &rlc_union_p->rlc.um, new_sdu_p); - //free_mem_block(new_sdu, __func__); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); - return RLC_OP_STATUS_OK; - } else { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); - free_mem_block(sdu_pP, __func__); - return RLC_OP_STATUS_INTERNAL_ERROR; - } - - break; - - case RLC_MODE_TM: - new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_tm_data_req_alloc), __func__); - - if (new_sdu_p != NULL) { - // PROCESS OF COMPRESSION HERE: - memset (new_sdu_p->data, 0, sizeof (struct rlc_tm_data_req_alloc)); - memcpy (&new_sdu_p->data[sizeof (struct rlc_tm_data_req_alloc)], &sdu_pP->data[0], sdu_sizeP); - ((struct rlc_tm_data_req *) (new_sdu_p->data))->data_size = sdu_sizeP; - ((struct rlc_tm_data_req *) (new_sdu_p->data))->data_offset = sizeof (struct rlc_tm_data_req_alloc); - free_mem_block(sdu_pP, __func__); - rlc_tm_data_req(ctxt_pP, &rlc_union_p->rlc.tm, new_sdu_p); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); - return RLC_OP_STATUS_OK; - } else { - //handle_event(ERROR,"FILE %s FONCTION rlc_data_req() LINE %s : out of memory\n", __FILE__, __LINE__); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); - free_mem_block(sdu_pP, __func__); - return RLC_OP_STATUS_INTERNAL_ERROR; - } - - break; - - default: - free_mem_block(sdu_pP, __func__); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); - return RLC_OP_STATUS_INTERNAL_ERROR; - } - } else { /* MBMS_flag != 0 */ - // LOG_I(RLC,"DUY rlc_data_req: mbms_rb_id in RLC instant is: %d\n", mbms_rb_id); - if (sdu_pP != NULL) { - if (sdu_sizeP > 0) { - LOG_D(RLC,"received a packet with size %d for MBMS \n", sdu_sizeP); - new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_um_data_req_alloc), __func__); - - if (new_sdu_p != NULL) { - // PROCESS OF COMPRESSION HERE: - memset (new_sdu_p->data, 0, sizeof (struct rlc_um_data_req_alloc)); - memcpy (&new_sdu_p->data[sizeof (struct rlc_um_data_req_alloc)], &sdu_pP->data[0], sdu_sizeP); - ((struct rlc_um_data_req *) (new_sdu_p->data))->data_size = sdu_sizeP; - ((struct rlc_um_data_req *) (new_sdu_p->data))->data_offset = sizeof (struct rlc_um_data_req_alloc); - free_mem_block(sdu_pP, __func__); - rlc_um_data_req(ctxt_pP, &rlc_union_p->rlc.um, new_sdu_p); - //free_mem_block(new_sdu, __func__); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); - return RLC_OP_STATUS_OK; - } else { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); - free_mem_block(sdu_pP, __func__); - return RLC_OP_STATUS_BAD_PARAMETER; - } - } else { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); - return RLC_OP_STATUS_BAD_PARAMETER; - } - } else { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); - return RLC_OP_STATUS_BAD_PARAMETER; - } - } -} - -//----------------------------------------------------------------------------- -void rlc_data_ind ( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_idP, - const sdu_size_t sdu_sizeP, - mem_block_t *sdu_pP) { - //----------------------------------------------------------------------------- - LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %ld] Display of rlc_data_ind: size %u\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - (srb_flagP) ? "SRB" : "DRB", - rb_idP, - sdu_sizeP); - rlc_util_print_hex_octets(RLC, (unsigned char *)sdu_pP->data, sdu_sizeP); - - if (ctxt_pP->enb_flag) { -#if T_TRACER - T(T_ENB_RLC_UL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_sizeP)); -#endif - const ngran_node_t type = RC.rrc[ctxt_pP->module_id]->node_type; - AssertFatal(!NODE_IS_CU(type), - "Can't be CU, bad node type %d\n", type); - - if (NODE_IS_DU(type) && srb_flagP == 1) { - MessageDef *msg = itti_alloc_new_message(TASK_RLC_ENB, F1AP_UL_RRC_MESSAGE); - F1AP_UL_RRC_MESSAGE(msg).rnti = ctxt_pP->rnti; - F1AP_UL_RRC_MESSAGE(msg).srb_id = rb_idP; - F1AP_UL_RRC_MESSAGE(msg).rrc_container = sdu_pP->data; - F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = sdu_sizeP; - itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), msg); - return; - } - } // case monolithic eNodeB or UE - - get_pdcp_data_ind_func()(ctxt_pP, srb_flagP, MBMS_flagP, rb_idP, sdu_sizeP, sdu_pP,NULL,NULL); -} -//----------------------------------------------------------------------------- -void rlc_data_conf (const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const rb_id_t rb_idP, - const mui_t muiP, - const rlc_tx_status_t statusP) { - //----------------------------------------------------------------------------- - if (srb_flagP) { - if (rlc_rrc_data_conf != NULL) { - rlc_rrc_data_conf (ctxt_pP, rb_idP, muiP, statusP); - } - } -} -//----------------------------------------------------------------------------- -int -rlc_module_init (int enb_flag) { /* enb_flag is unused, but needed for binary - * compatibility with rlc_v2 */ - //----------------------------------------------------------------------------- - int k; - module_id_t module_id1; - /* for no gcc warnings */ - (void)k; - LOG_D(RLC, "MODULE INIT\n"); - rlc_rrc_data_ind = NULL; - rlc_rrc_data_conf = NULL; - rlc_coll_p = hashtable_create ((LTE_maxDRB + 2) * NUMBER_OF_UE_MAX, NULL, rb_free_rlc_union); - - //AssertFatal(rlc_coll_p != NULL, "UNRECOVERABLE error, RLC hashtable_create failed"); - if(rlc_coll_p == NULL) { - LOG_E(RLC, "UNRECOVERABLE error, RLC hashtable_create failed\n"); - return -1; - } - - for (module_id1=0; module_id1 < MAX_MOBILES_PER_ENB; module_id1++) { - for (k=0; k < RLC_MAX_MBMS_LC; k++) { - rlc_mbms_lcid2service_session_id_ue[module_id1][k].service_id = 0; - rlc_mbms_lcid2service_session_id_ue[module_id1][k].session_id = 0; - } - - for (k=0; k < NB_RB_MBMS_MAX; k++) { - rlc_mbms_rbid2lcid_ue[module_id1][k] = RLC_LC_UNALLOCATED; - } - } - - for (k=0; k < RLC_MAX_MBMS_LC; k++) { - rlc_mbms_lcid2service_session_id_eNB[0][k].service_id = 0; - rlc_mbms_lcid2service_session_id_eNB[0][k].session_id = 0; - } - - for (k=0; k < NB_RB_MBMS_MAX; k++) { - rlc_mbms_rbid2lcid_eNB[0][k] = RLC_LC_UNALLOCATED; - } - - pool_buffer_init(); - return(0); -} -//----------------------------------------------------------------------------- -void -rlc_module_cleanup (void) -//----------------------------------------------------------------------------- -{ - hashtable_destroy(&rlc_coll_p); -} -//----------------------------------------------------------------------------- -void -rlc_layer_init (void) { - //----------------------------------------------------------------------------- -} -//----------------------------------------------------------------------------- -void -rlc_layer_cleanup (void) -//----------------------------------------------------------------------------- -{ -} - diff --git a/openair2/LAYER2/RLC/rlc.h b/openair2/LAYER2/RLC/rlc.h index 561a664d85056e772906434b5ff95721d61c0c05..32c3a70ea7bc28cccdaa87a075348e5cba08bfb3 100644 --- a/openair2/LAYER2/RLC/rlc.h +++ b/openair2/LAYER2/RLC/rlc.h @@ -38,12 +38,6 @@ # include "platform_types.h" #include "common/platform_constants.h" # include "hashtable.h" -# include "rlc_am.h" -# include "rlc_um.h" -# include "rlc_tm.h" -# include "rlc_am_structs.h" -# include "rlc_tm_structs.h" -# include "rlc_um_structs.h" # include "LTE_asn_constant.h" # include "common/utils/LOG/log.h" # include "mem_block.h" @@ -54,11 +48,8 @@ # include "LTE_SRB-ToAddMod.h" # include "LTE_SRB-ToAddModList.h" # include "LTE_DRB-ToReleaseList.h" +# include "LTE_PMCH-InfoList-r9.h" -#include "LTE_PMCH-InfoList-r9.h" - -typedef uint64_t hash_key_t; -#define HASHTABLE_NOT_A_KEY_VALUE ((uint64_t)-1) //----------------------------------------------------------------------------- #define RLC_OP_STATUS_OK 1 @@ -87,18 +78,6 @@ typedef enum rlc_mode_e { RLC_MODE_TM = 4 } rlc_mode_t; -/*! \struct rlc_info_t -* \brief Structure containing RLC protocol configuration parameters. -*/ -typedef volatile struct { - rlc_mode_t rlc_mode; - union { - rlc_am_info_t rlc_am_info; /*!< \sa rlc_am.h. */ - rlc_tm_info_t rlc_tm_info; /*!< \sa rlc_tm.h. */ - rlc_um_info_t rlc_um_info; /*!< \sa rlc_um.h. */ - } rlc; -} rlc_info_t; - /*! \struct mac_rlc_status_resp_t * \brief Primitive exchanged between RLC and MAC informing about the buffer occupancy of the RLC protocol instance. */ @@ -111,20 +90,6 @@ typedef struct { } mac_rlc_status_resp_t; -/*! \struct mac_rlc_max_rx_header_size_t -* \brief Usefull only for debug scenario where we connect 2 RLC protocol instances without the help of the MAC . -*/ -typedef struct { - union { - struct rlc_am_rx_pdu_management dummy1; - struct rlc_tm_rx_pdu_management dummy2; - //struct rlc_um_rx_pdu_management dummy3; - struct mac_tb_ind dummy4; - struct mac_rx_tb_management dummy5; - } dummy; -} mac_rlc_max_rx_header_size_t; - - //----------------------------------------------------------------------------- // PRIVATE INTERNALS OF RLC @@ -158,119 +123,6 @@ typedef void (rrc_data_conf_cb_t)( const rlc_tx_status_t statusP); -/*! \struct rlc_t -* \brief Structure to be instanciated to allocate memory for RLC protocol instances. -*/ -typedef struct rlc_union_s { - rlc_mode_t mode; - union { - rlc_am_entity_t am; - rlc_um_entity_t um; - rlc_tm_entity_t tm; - } rlc; -} rlc_union_t; - -typedef struct rlc_mbms_s { - rb_id_t rb_id; - module_id_t instanciated_instance; - rlc_um_entity_t um; -} rlc_mbms_t; - -typedef struct rlc_mbms_id_s { - mbms_service_id_t service_id; - mbms_session_id_t session_id; -} rlc_mbms_id_t; - - -//rlc_mbms_t rlc_mbms_array_ue[MAX_MOBILES_PER_ENB][maxServiceCount][maxSessionPerPMCH]; // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h -//rlc_mbms_t rlc_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH]; // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h -extern rlc_mbms_id_t rlc_mbms_lcid2service_session_id_ue[MAX_MOBILES_PER_ENB][RLC_MAX_MBMS_LC]; // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h -extern rlc_mbms_id_t rlc_mbms_lcid2service_session_id_eNB[MAX_eNB][RLC_MAX_MBMS_LC]; // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h - -#define rlc_mbms_enb_get_lcid_by_rb_id(Enb_mOD,rB_iD) rlc_mbms_rbid2lcid_eNB[Enb_mOD][rB_iD] -; - -#define rlc_mbms_enb_set_lcid_by_rb_id(Enb_mOD,rB_iD,lOG_cH_iD) do { \ - rlc_mbms_rbid2lcid_eNB[Enb_mOD][rB_iD] = lOG_cH_iD; \ - } while (0); - -#define rlc_mbms_ue_get_lcid_by_rb_id(uE_mOD,rB_iD) rlc_mbms_rbid2lcid_ue[uE_mOD][rB_iD] - -#define rlc_mbms_ue_set_lcid_by_rb_id(uE_mOD,rB_iD,lOG_cH_iD) do { \ - AssertFatal(rB_iD<NB_RB_MBMS_MAX, "INVALID RB ID %ld", rB_iD); \ - rlc_mbms_rbid2lcid_ue[uE_mOD][rB_iD] = lOG_cH_iD; \ - } while (0); - -extern logical_chan_id_t rlc_mbms_rbid2lcid_ue [MAX_MOBILES_PER_ENB][NB_RB_MBMS_MAX]; /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ -extern logical_chan_id_t rlc_mbms_rbid2lcid_eNB[MAX_eNB][NB_RB_MBMS_MAX]; /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ - - -#define RLC_COLL_KEY_VALUE(eNB_iD, rNTI, iS_eNB, rB_iD, iS_sRB) \ - ((hash_key_t)eNB_iD | \ - (((hash_key_t)(rNTI)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 24) | \ - (((hash_key_t)(rB_iD)) << 25) | \ - (((hash_key_t)(iS_sRB)) << 33) | \ - (((hash_key_t)(0x05)) << 34)) - -// index to the same RLC entity as RLC_COLL_KEY_VALUE(), but using LC_id instead -// the hidden last key indicates if this is a hash-key with RB_id (0x05) or LC_id (0x0a) -#define RLC_COLL_KEY_LCID_VALUE(eNB_iD, rNTI, iS_eNB, lC_iD, iS_sRB) \ - ((hash_key_t)eNB_iD | \ - (((hash_key_t)(rNTI)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 24) | \ - (((hash_key_t)(lC_iD)) << 25) | \ - (((hash_key_t)(iS_sRB)) << 33) | \ - (((hash_key_t)(0x0a)) << 34)) - -#define RLC_COLL_KEY_SOURCE_DEST_VALUE(eNB_iD, rNTI, iS_eNB, lC_iD, sOURCE_iD, dEST_iD, iS_sRB) \ - ((hash_key_t)eNB_iD | \ - (((hash_key_t)(rNTI)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 24) | \ - (((hash_key_t)(lC_iD)) << 25) | \ - (((hash_key_t)(dEST_iD)) << 33) | \ - (((hash_key_t)(0x05)) << 57)) - -#define RLC_COLL_KEY_LCID_SOURCE_DEST_VALUE(eNB_iD, rNTI, iS_eNB, lC_iD, sOURCE_iD, dEST_iD, iS_sRB) \ - ((hash_key_t)eNB_iD | \ - (((hash_key_t)(rNTI)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 24) | \ - (((hash_key_t)(lC_iD)) << 25) | \ - (((hash_key_t)(dEST_iD)) << 33) | \ - (((hash_key_t)(0x0a)) << 57)) - - -// service id max val is maxServiceCount = 16 (asn1_constants.h) - -#define RLC_COLL_KEY_MBMS_VALUE(eNB_iD, rNTI, iS_eNB, sERVICE_ID, sESSION_ID) \ - ((hash_key_t)eNB_iD | \ - (((hash_key_t)(rNTI)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 24) | \ - (((hash_key_t)(sERVICE_ID)) << 32) | \ - (((hash_key_t)(sESSION_ID)) << 37) | \ - (((hash_key_t)(0x0000000000000001)) << 63)) - -extern hash_table_t *rlc_coll_p __attribute__ ((aligned(32))); - -/*! \fn tbs_size_t mac_rlc_serialize_tb (char* bufferP, list_t transport_blocksP) -* \brief Serialize a list of transport blocks coming from RLC in order to be processed by MAC. -* \param[in] bufferP Memory area where the transport blocks have to be serialized. -* \param[in] transport_blocksP List of transport blocks. -* \return The amount of bytes that have been written due to serialization. -*/ -tbs_size_t mac_rlc_serialize_tb (char *, list_t); - -/*! \fn struct mac_data_ind mac_rlc_deserialize_tb (char* bufferP, tb_size_t tb_sizeP, num_tb_t num_tbP, crc_t *crcsP) -* \brief Serialize a list of transport blocks coming from RLC in order to be processed by MAC. -* \param[in] bufferP Memory area where the transport blocks are serialized. -* \param[in] tb_sizeP Size of transport blocks. -* \param[in] num_tbP Number of transport blocks. -* \param[in] crcsP Array of CRC for each transport block. -* \return A mac_data_ind structure containing a list of transport blocks. -*/ -struct mac_data_ind mac_rlc_deserialize_tb (char *, tb_size_t, num_tb_t, crc_t *); - - //----------------------------------------------------------------------------- // PUBLIC INTERFACE WITH RRC //----------------------------------------------------------------------------- @@ -293,16 +145,6 @@ rlc_op_status_t rrc_rlc_config_asn1_req ( const uint32_t, const uint32_t ); - -/*! \fn void rb_free_rlc_union (void *rlcu_pP) - * \brief Free the rlc memory contained in the RLC embedded in the rlc_union_t - * struct pointed by of the rlcu_pP parameter. Free the rlc_union_t struct also. - * \param[in] rlcu_pP Pointer on the rlc_union_t struct. - */ -void -rb_free_rlc_union (void *rlcu_pP); - - /*! \fn rlc_op_status_t rrc_rlc_remove_ue (const protocol_ctxt_t* const ctxtP) * \brief Remove all RLC protocol instances from all radio bearers allocated to a UE. * \param[in] ctxtP Running context. @@ -311,31 +153,6 @@ rb_free_rlc_union (void *rlcu_pP); rlc_op_status_t rrc_rlc_remove_ue (const protocol_ctxt_t *const); -/*! \fn rlc_op_status_t rrc_rlc_remove_rlc (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP) -* \brief Remove a RLC protocol instance from a radio bearer. -* \param[in] ctxtP Running context. -* \param[in] srb_flagP Flag to indicate SRB (1) or DRB (0) -* \param[in] MBMS_flag Flag to indicate whether this is an MBMS service (1) or not (0) -* \param[in] rb_idP Radio bearer identifier. -* \return A status about the processing, OK or error code. -*/ -rlc_op_status_t rrc_rlc_remove_rlc (const protocol_ctxt_t *const, const srb_flag_t, const MBMS_flag_t, const rb_id_t ); - -/*! \fn rlc_union_t* rrc_rlc_add_rlc (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, logical_chan_id_t chan_idP, rlc_mode_t rlc_modeP) -* \brief Add a RLC protocol instance to a radio bearer. -* \param[in] ctxtP Running context. -* \param[in] srb_flagP Flag to indicate SRB (1) or DRB (0) -* \param[in] MBMS_flag Flag to indicate whether this is an MBMS service (1) or not (0) -* \param[in] rb_idP Radio bearer identifier. -* \param[in] chan_idP Logical channel identifier. -* \param[in] rlc_modeP Mode of RLC (AM, UM, TM). -* \return A status about the processing, OK or error code. -*/ -rlc_union_t *rrc_rlc_add_rlc (const protocol_ctxt_t *const, const srb_flag_t, const MBMS_flag_t MBMS_flagP, const rb_id_t, logical_chan_id_t, rlc_mode_t - ,const uint32_t sourceL2Id, - const uint32_t destinationL2Id - ); - /*! \fn rlc_op_status_t rrc_rlc_config_req ( const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, @@ -352,13 +169,7 @@ rlc_union_t *rrc_rlc_add_rlc (const protocol_ctxt_t *const, const srb_flag * \param[in] rlc_infoP RLC configuration parameters issued from Radio Resource Manager. * \return A status about the processing, OK or error code. */ -rlc_op_status_t rrc_rlc_config_req ( - const protocol_ctxt_t *const, - const srb_flag_t, - const MBMS_flag_t, - config_action_t, - const rb_id_t, - rlc_info_t ); +rlc_op_status_t rrc_rlc_config_req(const protocol_ctxt_t *const, const srb_flag_t, const MBMS_flag_t, config_action_t, const rb_id_t); /*! \fn rlc_op_status_t rrc_rlc_data_req (const protocol_ctxt_t* const ctxtP, const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, char* sduP) * \brief Function for RRC to send a SDU through a Signalling Radio Bearer. diff --git a/openair2/LAYER2/RLC/rlc_def.h b/openair2/LAYER2/RLC/rlc_def.h deleted file mode 100644 index e7014043f74b7ce3bba049e459464c1e48773627..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/rlc_def.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_def.h -* \brief This file contains constants for RLC internal use. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \company Eurecom -* \email: lionel.gauthier@eurecom.fr -* \note -* \bug -* \warning -*/ -#ifndef __RLC_DEF_H__ -# define __RLC_DEF_H__ -//---------------------------------------------------------- -// protocol states -typedef enum rlc_protocol_state_e { - RLC_NULL_STATE = 0x00, - RLC_DATA_TRANSFER_READY_STATE = 0x01, - RLC_RESET_PENDING_STATE = 0x12, - RLC_RESET_AND_SUSPEND_STATE = 0x14, - RLC_LOCAL_SUSPEND_STATE = 0x08 -} rlc_protocol_state_t; -//---------------------------------------------------------- -enum RLC_OPERATION_MODE { TRANSMITTER_ONLY = 0x00, - RECEIVER_ONLY = 0x01, - TRANSMITTER_AND_RECEIVER = 0x02 - }; -#define JUMBO_FRAME 1 - -#ifdef JUMBO_FRAME -# define RLC_SDU_MAX_SIZE 9000 -# define RLC_SDU_MAX_SIZE_DATA_PLANE 9000 -# define RLC_MAX_FLEXIBLE_DATA_PDU_SIZE 8703 -#else -//---------------------------------------------------------- -# define RLC_SDU_MAX_SIZE 1800 -# define RLC_SDU_MAX_SIZE_DATA_PLANE 1800 -# define RLC_MAX_FLEXIBLE_DATA_PDU_SIZE 1503 -#endif - -# define RLC_SDU_MAX_SIZE_CONTROL_PLANE 2000 -//---------------------------------------------------------- -// dimensions -# define SN_12BITS_MASK 0x0FFF -# define RLC_SN_OVERFLOW 0xFFFF -# define RLC_SN_UNDEFINED RLC_SN_OVERFLOW -//---------------------------------------------------------- -// DISCARD -//---------------------------------------------------------- -enum RLC_SDU_DISCARD_MODE { SDU_DISCARD_MODE_RESET = 0x00, - SDU_DISCARD_MODE_TIMER_BASED_EXPLICIT = 0x01, - SDU_DISCARD_MODE_MAX_DAT_RETRANSMISSION = 0x04, - SDU_DISCARD_MODE_NOT_CONFIGURED = 0x10 - }; - - - -# define RLC_SDU_NO_DISCARD_MAX_DAT_RETRANSMISSION 0x00 -// AM (do not change this value) -# define RLC_SDU_DISCARD_TIMER_BASED_EXPLICIT 0x01 -// AM (must>0) -# define RLC_SDU_DISCARD_TIMER_BASED_NO_EXPLICIT 0x02 -// UM, TM (must>0) -# define RLC_SDU_DISCARD_MAX_DAT_RETRANSMISSION 0x04 -// AM (must>0) -# define RLC_SDU_DISCARD_NOT_CONFIGURED 0x10 -// UM, TM (must>0) -//---------------------------------------------------------- -// DATA, CONTROL PDU parameters -//---------------------------------------------------------- -// D/C field (values shifted 7 bits left) -# define RLC_DC_CONTROL_PDU 0 -# define RLC_DC_DATA_PDU 128 -# define RLC_DC_MASK 128 -// HE field -# define RLC_HE_SUCC_BYTE_CONTAINS_DATA 0x00 // v9.2 ok -# define RLC_HE_SUCC_BYTE_CONTAINS_LI_E 0x01 // v9.2 ok -# define RLC_HE_SUCC_BYTE_CONTAINS_DATA_END_PDU_IS_END_SDU 0x02 // v9.2 ok -# define RLC_HE_MASK 0x03 -// Extension bit -/* Section 9.2.2.5: -The interpretation of this bit depends on RLC mode and higher layer configuration: -- In the UMD PDU, the "Extension bit" in the first octet has either the normal - E-bit interpretation or the alternative E-bit interpretation depending on - higher layer configuration. The "Extension bit" in all the other octects always - has the normal E-bit interpretation. -- In the AMD PDU, the "Extension bit" always has the normal E-bit interpretation.*/ -# define RLC_E_NEXT_FIELD_IS_COMPLETE_SDU 0x00 // alternative E-bit interpretation v9.2 ok -# define RLC_E_NEXT_FIELD_IS_DATA 0x00 // v9.2 ok -# define RLC_E_NEXT_FIELD_IS_LI_E 0x01 // v9.2 ok -# define RLC_E_MASK 0x01 -// li field (values shifted 1 bit left) -# define RLC_LI_LAST_PDU_ONE_BYTE_SHORT 0xFFF6 // TO BE REMOVED ONLY FOR COMPILATION - -# define RLC_LI_LAST_PDU_EXACTLY_FILLED 0x0000 // v9.2 ok -# define RLC_LI_1ST_BYTE_PDU_IS_1ST_BYTE_SDU_LAST_BYTE_IGNORED 0xFFF4 // v9.2 ok UM only -# define RLC_LI_LAST_PDU_ONE_BYTE_SHORT_FILLED_BY_SDU 0xFFF6 // v9.2 ok -# define RLC_LI_1ST_BYTE_SDU_IS_1ST_BYTE_PDU 0xFFF8 // v9.2 ok UM only -# define RLC_LI_1ST_BYTE_SDU_IS_1ST_BYTE_PDU_LAST_BYTE_SDU_IS_LAST_BYTE_PDU 0xFFFA // v9.2 ok UM only -# define RLC_LI_PDU_PIGGY_BACKED_STATUS 0xFFFC // v9.2 ok AM -# define RLC_LI_PDU_NOT_FIRST_NOT_LAST_BYTE_SDU 0xFFFC // v9.2 ok UM only -# define RLC_LI_PDU_PADDING 0xFFFE // v9.2 ok -# define RLC_LI_UNDEFINED 0xF0F0 -# define RLC_LI_MASK 0xFFFE -// piggybacked status PDU (values shifted 4 bits left) -# define RLC_PIGGY_PDU_TYPE_STATUS 0x00 -# define RLC_PDU_TYPE_STATUS 0x00 // v9.2 ok -# define RLC_PIGGY_PDU_TYPE_RESET 0x10 -# define RLC_PDU_TYPE_RESET 0x10 // v9.2 ok -# define RLC_PIGGY_PDU_TYPE_RESET_ACK 0x20 -# define RLC_PDU_TYPE_RESET_ACK 0x20 // v9.2 ok -# define RLC_PIGGY_PDU_TYPE_MASK 0x70 -# define RLC_PDU_TYPE_MASK 0x70 // v9.2 ok - -# define GUARD_CRC_LIH_SIZE 0x03 -// in bytes - -#endif diff --git a/openair2/LAYER2/RLC/rlc_def_lte.h b/openair2/LAYER2/RLC/rlc_def_lte.h deleted file mode 100644 index aa4dac79ae354e32e4b4b28f432aa6fa0b236625..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/rlc_def_lte.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_def_lte.h -* \brief This file contains LTE constants for RLC internal use. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \company Eurecom -* \email: lionel.gauthier@eurecom.fr -* \note -* \bug -* \warning -*/ -#ifndef __RLC_DEF_LTE_H__ -# define __RLC_DEF_LTE_H__ -//---------------------------------------------------------- - -# define RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU 0x0 -# define RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU 0x1 -# define RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU 0x2 -# define RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU 0x3 - -# define RLC_E_FIXED_PART_DATA_FIELD_FOLLOW 0x0 -# define RLC_E_FIXED_PART_E_AND_LI_FIELD_FOLLOW 0x1 - -# define RLC_E_EXTENSION_PART_DATA_FIELD_FOLLOW 0x0 -# define RLC_E_EXTENSION_PART_E_AND_LI_FIELD_FOLLOW 0x1 - -#endif diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c deleted file mode 100644 index 2e308fc0e1c775ba1a5c0976bda16348a966281c..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/* - rlc_mac.c - ------------------- - AUTHOR : Lionel GAUTHIER - COMPANY : EURECOM - EMAIL : Lionel.Gauthier@eurecom.fr -*/ - -//----------------------------------------------------------------------------- -#define RLC_MAC_C -#include "rlc.h" -#include "LAYER2/RLC/UM_v9.3.0/rlc_um.h" -#include "LAYER2/MAC/mac_extern.h" -#include "common/utils/LOG/log.h" -#include "UTIL/OCG/OCG_vars.h" -#include "hashtable.h" -#include "assertions.h" -#include "common/utils/LOG/vcd_signal_dumper.h" -#include "openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h" - -//#define DEBUG_MAC_INTERFACE 1 - -//----------------------------------------------------------------------------- -struct mac_data_ind mac_rlc_deserialize_tb ( - char *buffer_pP, - const tb_size_t tb_sizeP, - num_tb_t num_tbP, - crc_t *crcs_pP) { - //----------------------------------------------------------------------------- - struct mac_data_ind data_ind; - mem_block_t *tb_p; - num_tb_t nb_tb_read; - tbs_size_t tbs_size; - nb_tb_read = 0; - tbs_size = 0; - list_init(&data_ind.data, NULL); - - while (num_tbP > 0) { - tb_p = get_free_mem_block(sizeof (mac_rlc_max_rx_header_size_t) + tb_sizeP, __func__); - - if (tb_p != NULL) { - ((struct mac_tb_ind *) (tb_p->data))->first_bit = 0; - ((struct mac_tb_ind *) (tb_p->data))->data_ptr = (uint8_t *)&tb_p->data[sizeof (mac_rlc_max_rx_header_size_t)]; - ((struct mac_tb_ind *) (tb_p->data))->size = tb_sizeP; - - if (crcs_pP) { - ((struct mac_tb_ind *) (tb_p->data))->error_indication = crcs_pP[nb_tb_read]; - } else { - ((struct mac_tb_ind *) (tb_p->data))->error_indication = 0; - } - - memcpy(((struct mac_tb_ind *) (tb_p->data))->data_ptr, &buffer_pP[tbs_size], tb_sizeP); -#ifdef DEBUG_MAC_INTERFACE - LOG_T(RLC, "[MAC-RLC] DUMP RX PDU(%d bytes):\n", tb_sizeP); - rlc_util_print_hex_octets(RLC, ((struct mac_tb_ind *) (tb_p->data))->data_ptr, tb_sizeP); -#endif - nb_tb_read = nb_tb_read + 1; - tbs_size = tbs_size + tb_sizeP; - list_add_tail_eurecom(tb_p, &data_ind.data); - } - - num_tbP = num_tbP - 1; - } - - data_ind.no_tb = nb_tb_read; - data_ind.tb_size = tb_sizeP << 3; - return data_ind; -} -//----------------------------------------------------------------------------- -tbs_size_t mac_rlc_serialize_tb (char *buffer_pP, list_t transport_blocksP) { - //----------------------------------------------------------------------------- - mem_block_t *tb_p; - tbs_size_t tbs_size; - tbs_size_t tb_size; - tbs_size = 0; - - while (transport_blocksP.nb_elements > 0) { - tb_p = list_remove_head (&transport_blocksP); - - if (tb_p != NULL) { - tb_size = ((struct mac_tb_req *) (tb_p->data))->tb_size; -#ifdef DEBUG_MAC_INTERFACE - LOG_T(RLC, "[MAC-RLC] DUMP TX PDU(%d bytes):\n", tb_size); - rlc_util_print_hex_octets(RLC, ((struct mac_tb_req *) (tb_p->data))->data_ptr, tb_size); -#endif - memcpy(&buffer_pP[tbs_size], &((struct mac_tb_req *) (tb_p->data))->data_ptr[0], tb_size); - tbs_size = tbs_size + tb_size; - free_mem_block(tb_p, __func__); - } - } - - return tbs_size; -} -//----------------------------------------------------------------------------- -tbs_size_t mac_rlc_data_req( - const module_id_t module_idP, - const rnti_t rntiP, - const eNB_index_t eNB_index, - const frame_t frameP, - const eNB_flag_t enb_flagP, - const MBMS_flag_t MBMS_flagP, - const logical_chan_id_t channel_idP, - const tb_size_t tb_sizeP, - char *buffer_pP, - const uint32_t sourceL2Id, - const uint32_t destinationL2Id -) { - //----------------------------------------------------------------------------- - struct mac_data_req data_request; - rlc_mode_t rlc_mode = RLC_MODE_NONE; - rlc_mbms_id_t *mbms_id_p = NULL; - rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - srb_flag_t srb_flag = (channel_idP <= 2) ? SRB_FLAG_YES : SRB_FLAG_NO; - tbs_size_t ret_tb_size = 0; - protocol_ctxt_t ctxt; - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, enb_flagP, rntiP, frameP, 0,eNB_index); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_DATA_REQ,VCD_FUNCTION_IN); -#ifdef DEBUG_MAC_INTERFACE - LOG_D(RLC, PROTOCOL_CTXT_FMT" MAC_RLC_DATA_REQ channel %d (%d) MAX RB %d\n", - PROTOCOL_CTXT_ARGS((&ctxt)), - channel_idP, - RLC_MAX_LC, - NB_RB_MAX); -#endif // DEBUG_MAC_INTERFACE - - if (MBMS_flagP) { - //AssertFatal (channel_idP < RLC_MAX_MBMS_LC, "channel id is too high (%u/%d)!\n", channel_idP, RLC_MAX_MBMS_LC); - if(channel_idP >= RLC_MAX_MBMS_LC) { - LOG_E(RLC, "channel id is too high (%u/%d)!\n", channel_idP, RLC_MAX_MBMS_LC); - return 0; - } - } else { - //AssertFatal (channel_idP < NB_RB_MAX, "channel id is too high (%u/%d)!\n", channel_idP, NB_RB_MAX); - if(channel_idP >= NB_RB_MAX) { - LOG_E(RLC, "channel id is too high (%u/%d)!\n", channel_idP, NB_RB_MAX); - return 0; - } - } - - if (MBMS_flagP) { - if (enb_flagP) { - mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[module_idP][channel_idP]; - key = RLC_COLL_KEY_MBMS_VALUE(module_idP, rntiP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id); - } else { - return (tbs_size_t)0; - } - } else { - key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); - - if ((sourceL2Id > 0) && (destinationL2Id > 0)) - key = RLC_COLL_KEY_LCID_SOURCE_DEST_VALUE(module_idP, rntiP, enb_flagP, channel_idP, sourceL2Id, destinationL2Id, srb_flag); - } - - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - if (h_rc == HASH_TABLE_OK) { - rlc_mode = rlc_union_p->mode; - } else { - rlc_mode = RLC_MODE_NONE; - //AssertFatal (0 , "RLC not configured lcid %u RNTI %x!\n", channel_idP, rntiP); - LOG_E(RLC, "RLC not configured lcid %u RNTI %x!\n", channel_idP, rntiP); - } - - switch (rlc_mode) { - case RLC_MODE_NONE: - ret_tb_size =0; - break; - - case RLC_MODE_AM: - rlc_am_mui.rrc_mui_num = 0; - - ((rlc_am_entity_t *) &rlc_union_p->rlc.am)->nb_bytes_requested_by_mac = tb_sizeP; - data_request = rlc_am_mac_data_request(&ctxt, &rlc_union_p->rlc.am,enb_flagP); - ret_tb_size =mac_rlc_serialize_tb(buffer_pP, data_request.data); - break; - - case RLC_MODE_UM: - ((rlc_um_entity_t *) &rlc_union_p->rlc.um)->nb_bytes_requested_by_mac = tb_sizeP; - data_request = rlc_um_mac_data_request(&ctxt, &rlc_union_p->rlc.um,enb_flagP); - ret_tb_size = mac_rlc_serialize_tb(buffer_pP, data_request.data); - break; - - case RLC_MODE_TM: - ((rlc_tm_entity_t *) &rlc_union_p->rlc.tm)->rlc_pdu_size = tb_sizeP; - data_request = rlc_tm_mac_data_request(&ctxt, &rlc_union_p->rlc.tm); - ret_tb_size = mac_rlc_serialize_tb(buffer_pP, data_request.data); - break; - - default: - ; - } - -#if T_TRACER - - if (enb_flagP) - T(T_ENB_RLC_MAC_DL, T_INT(module_idP), T_INT(rntiP), T_INT(channel_idP), T_INT(ret_tb_size)); - -#endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_DATA_REQ,VCD_FUNCTION_OUT); - return ret_tb_size; -} -//----------------------------------------------------------------------------- -void mac_rlc_data_ind ( - const module_id_t module_idP, - const rnti_t rntiP, - const eNB_index_t eNB_index, - const frame_t frameP, - const eNB_flag_t enb_flagP, - const MBMS_flag_t MBMS_flagP, - const logical_chan_id_t channel_idP, - char *buffer_pP, - const tb_size_t tb_sizeP, - num_tb_t num_tbP, - crc_t *crcs_pP) { - //----------------------------------------------------------------------------- - rlc_mode_t rlc_mode = RLC_MODE_NONE; - rlc_mbms_id_t *mbms_id_p = NULL; - rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - srb_flag_t srb_flag = (channel_idP <= 2) ? SRB_FLAG_YES : SRB_FLAG_NO; - protocol_ctxt_t ctxt; - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, enb_flagP, rntiP, frameP, 0, eNB_index); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_DATA_IND,VCD_FUNCTION_IN); -#ifdef DEBUG_MAC_INTERFACE - - if (num_tbP) { - LOG_D(RLC, PROTOCOL_CTXT_FMT" MAC_RLC_DATA_IND on channel %d (%d), rb max %d, tb_sizeP %d\n", - PROTOCOL_CTXT_ARGS(&ctxt), - channel_idP, - RLC_MAX_LC, - NB_RB_MAX, - tb_sizeP); - } - -#endif // DEBUG_MAC_INTERFACE -#if T_TRACER - - if (enb_flagP) - T(T_ENB_RLC_MAC_UL, T_INT(module_idP), T_INT(rntiP), T_INT(channel_idP), T_INT(tb_sizeP)); - -#endif - - if (MBMS_flagP) { - if (BOOL_NOT(enb_flagP)) { - mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[module_idP][channel_idP]; - key = RLC_COLL_KEY_MBMS_VALUE(module_idP, rntiP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id); - } else { - return; - } - } else { - key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); - } - - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - if (h_rc == HASH_TABLE_OK) { - rlc_mode = rlc_union_p->mode; - } else { - rlc_mode = RLC_MODE_NONE; - //AssertFatal (0 , "%s RLC not configured lcid %u ! (h_rc %d)\n", __FUNCTION__,channel_idP,h_rc); - } - - struct mac_data_ind data_ind = mac_rlc_deserialize_tb(buffer_pP, tb_sizeP, num_tbP, crcs_pP); - - switch (rlc_mode) { - case RLC_MODE_NONE: - //handle_event(WARNING,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : no radio bearer configured :%d\n", __FILE__, __LINE__, channel_idP); - list_free (&data_ind.data); - break; - - case RLC_MODE_AM: - rlc_am_mac_data_indication(&ctxt, &rlc_union_p->rlc.am, data_ind); - break; - - case RLC_MODE_UM: - rlc_um_mac_data_indication(&ctxt, &rlc_union_p->rlc.um, data_ind); - break; - - case RLC_MODE_TM: - rlc_tm_mac_data_indication(&ctxt, &rlc_union_p->rlc.tm, data_ind); - break; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_DATA_IND,VCD_FUNCTION_OUT); -} -//----------------------------------------------------------------------------- -mac_rlc_status_resp_t mac_rlc_status_ind( - const module_id_t module_idP, - const rnti_t rntiP, - const eNB_index_t eNB_index, - const frame_t frameP, - const sub_frame_t subframeP, - const eNB_flag_t enb_flagP, - const MBMS_flag_t MBMS_flagP, - const logical_chan_id_t channel_idP, - const uint32_t sourceL2Id, - const uint32_t destinationL2Id -) { - //----------------------------------------------------------------------------- - mac_rlc_status_resp_t mac_rlc_status_resp; - struct mac_status_ind tx_status; - struct mac_status_resp status_resp; - rlc_mode_t rlc_mode = RLC_MODE_NONE; - rlc_mbms_id_t *mbms_id_p = NULL; - rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - srb_flag_t srb_flag = (channel_idP <= 2) ? SRB_FLAG_YES : SRB_FLAG_NO; - protocol_ctxt_t ctxt; - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, enb_flagP, rntiP, frameP, subframeP, eNB_index); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_STATUS_IND,VCD_FUNCTION_IN); - memset (&mac_rlc_status_resp, 0, sizeof(mac_rlc_status_resp_t)); - memset (&tx_status, 0, sizeof(struct mac_status_ind)); - - if (MBMS_flagP) { - if (enb_flagP) { - mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[module_idP][channel_idP]; - } else { - mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[module_idP][channel_idP]; - } - - key = RLC_COLL_KEY_MBMS_VALUE(module_idP, rntiP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id); - } else { - if ((sourceL2Id > 0) && (destinationL2Id > 0)) { - key = RLC_COLL_KEY_SOURCE_DEST_VALUE(module_idP, rntiP, enb_flagP, channel_idP, sourceL2Id, destinationL2Id, srb_flag); - } else { - key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); - } - } - - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - if (h_rc == HASH_TABLE_OK) { - rlc_mode = rlc_union_p->mode; - } else { - rlc_mode = RLC_MODE_NONE; - //LOG_W(RLC , "[%s] RLC not configured lcid %u module %u!\n", __FUNCTION__, channel_idP, module_idP); - //LOG_D(RLC , "[%s] RLC not configured rb id %u lcid %u module %u!\n", __FUNCTION__, rb_id, channel_idP, ue_module_idP); - } - - switch (rlc_mode) { - case RLC_MODE_NONE: - //handle_event(WARNING,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : no radio bearer configured :%d\n", __FILE__, __LINE__, channel_idP); - mac_rlc_status_resp.bytes_in_buffer = 0; - break; - - case RLC_MODE_AM: - status_resp = rlc_am_mac_status_indication(&ctxt, &rlc_union_p->rlc.am, tx_status,enb_flagP); - mac_rlc_status_resp.bytes_in_buffer = status_resp.buffer_occupancy_in_bytes; - mac_rlc_status_resp.head_sdu_creation_time = status_resp.head_sdu_creation_time; - mac_rlc_status_resp.head_sdu_remaining_size_to_send = status_resp.head_sdu_remaining_size_to_send; - mac_rlc_status_resp.head_sdu_is_segmented = status_resp.head_sdu_is_segmented; - //return mac_rlc_status_resp; - break; - - case RLC_MODE_UM: - status_resp = rlc_um_mac_status_indication(&ctxt, &rlc_union_p->rlc.um, tx_status, enb_flagP); - mac_rlc_status_resp.bytes_in_buffer = status_resp.buffer_occupancy_in_bytes; - mac_rlc_status_resp.pdus_in_buffer = status_resp.buffer_occupancy_in_pdus; - mac_rlc_status_resp.head_sdu_creation_time = status_resp.head_sdu_creation_time; - mac_rlc_status_resp.head_sdu_remaining_size_to_send = status_resp.head_sdu_remaining_size_to_send; - mac_rlc_status_resp.head_sdu_is_segmented = status_resp.head_sdu_is_segmented; - // return mac_rlc_status_resp; - break; - - case RLC_MODE_TM: - status_resp = rlc_tm_mac_status_indication(&ctxt, &rlc_union_p->rlc.tm, tx_status); - mac_rlc_status_resp.bytes_in_buffer = status_resp.buffer_occupancy_in_bytes; - mac_rlc_status_resp.pdus_in_buffer = status_resp.buffer_occupancy_in_pdus; - // return mac_rlc_status_resp; - break; - - default: - mac_rlc_status_resp.bytes_in_buffer = 0 ; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_STATUS_IND,VCD_FUNCTION_OUT); - return mac_rlc_status_resp; -} - -//----------------------------------------------------------------------------- -rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind( - const module_id_t module_idP, - const rnti_t rntiP, - const eNB_index_t eNB_index, - const frame_t frameP, - const sub_frame_t subframeP, - const eNB_flag_t enb_flagP, - const logical_chan_id_t channel_idP) { - //----------------------------------------------------------------------------- - rlc_buffer_occupancy_t mac_rlc_buffer_occupancy_resp = 0; - rlc_mode_t rlc_mode = RLC_MODE_NONE; - rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - srb_flag_t srb_flag = (channel_idP <= 2) ? SRB_FLAG_YES : SRB_FLAG_NO; - protocol_ctxt_t ctxt; - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, enb_flagP, rntiP, frameP, 0, eNB_index); - - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_GET_BUFFER_OCCUPANCY_IND,VCD_FUNCTION_IN); - - /* Assumptions : for UE only */ - /* At each TTI, Buffer Occupancy is first computed in mac_rlc_status_ind called by MAC ue_scheduler() function */ - /* Then this function is called during MAC multiplexing ue_get_sdu(), and it may be call several times for the same bearer if it is in AM mode and there are several PDU types to transmit */ - //AssertFatal(enb_flagP == false,"RLC Tx mac_rlc_get_buffer_occupancy_ind function is not implemented for eNB LcId=%d\n", channel_idP); - if(enb_flagP != false) { - LOG_E(RLC, "Tx mac_rlc_get_buffer_occupancy_ind function is not implemented for eNB LcId=%u\n", channel_idP); - return 0; - } - - key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - if (h_rc == HASH_TABLE_OK) { - rlc_mode = rlc_union_p->mode; - } else { - rlc_mode = RLC_MODE_NONE; - //LOG_W(RLC , "[%s] RLC not configured rb id %u lcid %u module %u!\n", __FUNCTION__, rb_id, channel_idP, ue_module_idP); - //LOG_D(RLC , "[%s] RLC not configured rb id %u lcid %u module %u!\n", __FUNCTION__, rb_id, channel_idP, ue_module_idP); - } - - switch (rlc_mode) { - case RLC_MODE_AM: - mac_rlc_buffer_occupancy_resp = rlc_am_get_buffer_occupancy_in_bytes(&ctxt, &rlc_union_p->rlc.am); - break; - - case RLC_MODE_UM: - mac_rlc_buffer_occupancy_resp = rlc_um_get_buffer_occupancy(&rlc_union_p->rlc.um); - break; - - default: - mac_rlc_buffer_occupancy_resp = 0 ; - } - - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_GET_BUFFER_OCCUPANCY_IND,VCD_FUNCTION_OUT); - return mac_rlc_buffer_occupancy_resp; -} - - diff --git a/openair2/LAYER2/RLC/rlc_mpls.c b/openair2/LAYER2/RLC/rlc_mpls.c deleted file mode 100644 index 754f1e76aaf4744d97dfaee56333c4ed4c4e501f..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/rlc_mpls.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/* - rlc_mpls.c - ------------------- - AUTHOR : Lionel GAUTHIER - COMPANY : EURECOM - EMAIL : Lionel.Gauthier@eurecom.fr -*/ - -#define RLC_MPLS_C -#include "rlc.h" - - -//----------------------------------------------------------------------------- -rlc_op_status_t mpls_rlc_data_req ( - const protocol_ctxt_t *const ctxtP, - const rb_id_t rb_idP, - const sdu_size_t sdu_sizeP, - mem_block_t *const sduP) { - //----------------------------------------------------------------------------- - // third arg should be set to 1 or 0 - return rlc_data_req(ctxtP, SRB_FLAG_NO, MBMS_FLAG_NO, rb_idP, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, sdu_sizeP, sduP,NULL, NULL ); -} - diff --git a/openair2/LAYER2/RLC/rlc_primitives.h b/openair2/LAYER2/RLC/rlc_primitives.h deleted file mode 100644 index 0e751855d55e47f70a9c0ba5e7bfb63827ef9394..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/rlc_primitives.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rlc_primitives.h -* \brief This file contains constants definition for RLC primitives. -* \author GAUTHIER Lionel -* \date 2010-2011 -* \version -* \note -* \bug -* \warning -*/ -#ifndef __RLC_PRIMITIVES_H__ -# define __RLC_PRIMITIVES_H__ - -# include <stdio.h> -# include <stdlib.h> -# include "platform_types.h" -#include "common/platform_constants.h" -# include "mem_block.h" - - -# define RLC_NO_SAP RLC_NONE -# define RLC_AM_SAP RLC_MODE_AM -# define RLC_UM_SAP RLC_MODE_UM -# define RLC_TM_SAP RLC_MODE_TM -//---------------------------------------------------------- -// primitives -//---------------------------------------------------------- -# define RLC_AM_DATA_REQ 0x01 -# define RLC_UM_DATA_REQ 0x02 -# define RLC_TM_DATA_REQ 0x04 - -# define RLC_AM_DATA_IND 0x08 -# define RLC_UM_DATA_IND 0x10 -# define RLC_TM_DATA_IND 0x20 - -# define RLC_AM_DATA_CNF 0x40 -//---------------------------------------------------------- -// control primitives -//---------------------------------------------------------- -# define CRLC_CONFIG_REQ 0x81 -# define CRLC_SUSPEND_REQ 0x82 -# define CRLC_SUSPEND_CONF 0x84 -# define CRLC_RESUME_REQ 0x88 -# define CRLC_STATUS_IND 0x90 -//---------------------------------------------------------- -// primitives definition -//---------------------------------------------------------- -# define RLC_AM_SDU_MNGT_LAST_PDU_SN_EXTENDS_ABOVE_CONF_TX_WINDOW 0X4000 -# define RLC_AM_SDU_MNGT_LAST_PDU_SN_UNKNOWN 0X8000 -# define RLC_TX_CONFIRM_SUCCESSFULL 0xCF -# define RLC_TX_CONFIRM_FAILURE 0xFA - -struct rlc_am_data_req { - //struct rlc_am_sdu_management sdu_mngt; - uint32_t mui; - uint16_t data_size; // in bytes - uint16_t data_offset; // beginning of payload data may not start just after the header (PDCP header compression, etc) - uint8_t conf; // confirm of sdu delivery to the peer entity -}; - -struct rlc_tm_data_req { - uint16_t data_size; // in bits - uint16_t data_offset; // beginning of payload data may not start just after the header (PDCP header compression, etc) -}; - - -struct rlc_um_data_req { - uint16_t data_size; // in bytes - uint16_t data_offset; // beginning of payload data may not start just after the header (PDCP header compression, etc) - uint8_t use_special_li; -}; - -typedef struct rlc_am_data_req rlc_am_data_req_t; -typedef struct rlc_tm_data_req rlc_tm_data_req_t; -typedef struct rlc_um_data_req rlc_um_data_req_t; - -//---------------------------------------------------------- -// control primitives definition -//---------------------------------------------------------- -# define RLC_E_R_RELEASE 0x00 -# define RLC_E_R_MODIFICATION 0x01 -# define RLC_E_R_ESTABLISHMENT 0x02 -# define RLC_E_R_RE_ESTABLISHMENT 0x04 -# define RLC_STOP 0x08 -# define RLC_CONTINUE 0x10 - -# define RLC_TM_SEGMENTATION_NOT_ALLOWED 0x00 -# define RLC_TM_SEGMENTATION_ALLOWED 0x01 - -# define RLC_TM_DELIVERY_OF_ERRONEOUS_SDU_NO 0x01 -# define RLC_TM_DELIVERY_OF_ERRONEOUS_SDU_YES 0x02 -# define RLC_TM_DELIVERY_OF_ERRONEOUS_SDU_NO_DETECT 0x04 - - -struct rlc_am_parameters { - uint8_t rb_id; - uint8_t e_r; // reestablishment, release or modification of the rlc - uint8_t stop; - uint8_t cont; // continue - // timers - uint32_t *frame_tick_milliseconds; - - uint16_t timer_poll; - uint16_t timer_poll_prohibit; - uint16_t timer_epc; - uint16_t timer_discard; - uint16_t timer_poll_periodic; - uint16_t timer_status_prohibit; - uint16_t timer_status_periodic; - uint16_t timer_rst; - uint8_t max_rst; - uint16_t timer_mrw; - - // protocol_parameters - uint16_t pdu_size; // in bits - uint8_t missing_pdu_indicator; - uint8_t in_sequence_delivery; // no action : this version always deliver sdus in sequence - uint16_t max_dat; - uint16_t poll_pdu; - uint16_t poll_sdu; - uint8_t poll_window; // in percent of the window - uint16_t configured_tx_window_size; - uint16_t configured_rx_window_size; - uint16_t max_mrw; - - uint8_t last_transmission_pdu_poll_trigger; - uint8_t last_retransmission_pdu_poll_trigger; - uint8_t sdu_discard_mode; - uint8_t send_mrw; -}; - -struct rlc_um_parameters { - uint32_t *frame_tick_milliseconds; - uint8_t rb_id; - uint8_t e_r; // reestablishment, release or modification of the rlc - uint8_t stop; - uint8_t cont; // continue - uint8_t sdu_discard_mode; - uint16_t timer_discard; - uint16_t size_input_sdus_buffer; -}; - -struct rlc_tm_parameters { - uint32_t *frame_tick_milliseconds; - uint8_t rb_id; - uint8_t e_r; // reestablishment, release or modification of the rlc - uint8_t sdu_discard_mode; - uint8_t segmentation_indication; - uint8_t delivery_of_erroneous_sdu; - uint16_t timer_discard; - uint16_t size_input_sdus_buffer; -}; - - -struct crlc_config_req { - union { - struct rlc_am_parameters am_parameters; - struct rlc_um_parameters um_parameters; - struct rlc_tm_parameters tm_parameters; - } parameters; -}; - -struct crlc_suspend_conf { - uint16_t vt_s_or_vt_us; -}; - -struct crlc_resume_req { - // no parameters - uint8_t todo; -}; - -struct crlc_status_ind { - uint16_t evc; -}; - -struct crlc_primitive { - uint8_t type; - union { - struct crlc_config_req c_config_req; - struct crlc_suspend_conf c_suspend_conf; - struct crlc_resume_req c_resume_req; - struct crlc_status_ind c_status_ind; - } primitive; -}; - -#endif diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c deleted file mode 100644 index ed9af5efb2541c46d87c8a30637c46b06565022e..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ /dev/null @@ -1,788 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/* - rlc_rrc.c - ------------------- - AUTHOR : Lionel GAUTHIER - COMPANY : EURECOM - EMAIL : Lionel.Gauthier at eurecom dot fr -*/ - -#define RLC_RRC_C -#include "rlc.h" -#include "rlc_am.h" -#include "rlc_um.h" -#include "rlc_tm.h" -#include "common/utils/LOG/log.h" -#include "LTE_RLC-Config.h" -#include "LTE_DRB-ToAddMod.h" -#include "LTE_DRB-ToAddModList.h" -#include "LTE_SRB-ToAddMod.h" -#include "LTE_SRB-ToAddModList.h" -#include "LTE_DL-UM-RLC.h" -#include "LTE_PMCH-InfoList-r9.h" - -#include "LAYER2/MAC/mac_extern.h" -#include "assertions.h" -//----------------------------------------------------------------------------- -rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t *const ctxt_pP, - const LTE_SRB_ToAddModList_t *const srb2add_listP, - const LTE_DRB_ToAddModList_t *const drb2add_listP, - const LTE_DRB_ToReleaseList_t *const drb2release_listP, - const LTE_PMCH_InfoList_r9_t *const pmch_InfoList_r9_pP, - const uint32_t sourceL2Id, - const uint32_t destinationL2Id - - ) { - //----------------------------------------------------------------------------- - rb_id_t rb_id = 0; - logical_chan_id_t lc_id = 0; - LTE_DRB_Identity_t drb_id = 0; - LTE_DRB_Identity_t *pdrb_id = NULL; - long int cnt = 0; - const LTE_SRB_ToAddMod_t *srb_toaddmod_p = NULL; - const LTE_DRB_ToAddMod_t *drb_toaddmod_p = NULL; - rlc_union_t *rlc_union_p = NULL; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - int i, j; - LTE_MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9_p = NULL; - LTE_MBMS_SessionInfo_r9_t *MBMS_SessionInfo_p = NULL; - mbms_session_id_t mbms_session_id; - mbms_service_id_t mbms_service_id; - LTE_DL_UM_RLC_t dl_um_rlc; - /* for no gcc warnings */ - (void)rlc_union_p; - (void)key; - (void)h_rc; - LOG_D(RLC, PROTOCOL_CTXT_FMT" CONFIG REQ ASN1 \n", - PROTOCOL_CTXT_ARGS(ctxt_pP)); - - if (srb2add_listP != NULL) { - for (cnt=0; cnt<srb2add_listP->list.count; cnt++) { - rb_id = srb2add_listP->list.array[cnt]->srb_Identity; - lc_id = rb_id; - LOG_D(RLC, "Adding SRB %ld, rb_id %ld\n",srb2add_listP->list.array[cnt]->srb_Identity,rb_id); - srb_toaddmod_p = srb2add_listP->list.array[cnt]; - - if (srb_toaddmod_p->rlc_Config) { - switch (srb_toaddmod_p->rlc_Config->present) { - case LTE_SRB_ToAddMod__rlc_Config_PR_NOTHING: - break; - - case LTE_SRB_ToAddMod__rlc_Config_PR_explicitValue: - switch (srb_toaddmod_p->rlc_Config->choice.explicitValue.present) { - case LTE_RLC_Config_PR_NOTHING: - break; - - case LTE_RLC_Config_PR_am: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_AM,0, 0 ) != NULL) { - config_req_rlc_am_asn1 ( - ctxt_pP, - SRB_FLAG_YES, - &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.am, - rb_id, lc_id); - } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %ld \n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_id); - } - - break; - - case LTE_RLC_Config_PR_um_Bi_Directional: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM,0,0 ) != NULL) { - config_req_rlc_um_asn1( - ctxt_pP, - SRB_FLAG_YES, - MBMS_FLAG_NO, - UNUSED_PARAM_MBMS_SESSION_ID, - UNUSED_PARAM_MBMS_SERVICE_ID, - &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Bi_Directional.ul_UM_RLC, - &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Bi_Directional.dl_UM_RLC, - rb_id, lc_id,0, 0 - ); - } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %ld \n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_id); - } - - break; - - case LTE_RLC_Config_PR_um_Uni_Directional_UL: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM,0, 0 ) != NULL) { - config_req_rlc_um_asn1( - ctxt_pP, - SRB_FLAG_YES, - MBMS_FLAG_NO, - UNUSED_PARAM_MBMS_SESSION_ID, - UNUSED_PARAM_MBMS_SERVICE_ID, - &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Uni_Directional_UL.ul_UM_RLC, - NULL, - rb_id, lc_id,0, 0 - ); - } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %ld \n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_id); - } - - break; - - case LTE_RLC_Config_PR_um_Uni_Directional_DL: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM,0, 0 ) != NULL) { - config_req_rlc_um_asn1( - ctxt_pP, - SRB_FLAG_YES, - MBMS_FLAG_NO, - UNUSED_PARAM_MBMS_SESSION_ID, - UNUSED_PARAM_MBMS_SERVICE_ID, - NULL, - &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Uni_Directional_DL.dl_UM_RLC, - rb_id, lc_id,0, 0 - ); - } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %ld \n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_id); - } - - break; - - default: - LOG_E(RLC, PROTOCOL_CTXT_FMT" UNKNOWN RLC CONFIG %d \n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - srb_toaddmod_p->rlc_Config->choice.explicitValue.present); - break; - } - - break; - - case LTE_SRB_ToAddMod__rlc_Config_PR_defaultValue: - //#warning TO DO SRB_ToAddMod__rlc_Config_PR_defaultValue - LOG_I(RRC, "RLC SRB1 is default value !!\n"); - struct LTE_RLC_Config__am *config_am_pP = &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.am; - config_am_pP->dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; - config_am_pP->dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms0; - config_am_pP->ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms45; - config_am_pP->ul_AM_RLC.pollPDU = LTE_PollPDU_pInfinity; - config_am_pP->ul_AM_RLC.pollByte = LTE_PollByte_kBinfinity; - config_am_pP->ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t4; - - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_AM,0, 0 ) != NULL) { - config_req_rlc_am_asn1 ( - ctxt_pP, - SRB_FLAG_YES, - &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.am, - rb_id,lc_id); - } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %ld \n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_id); - } - - /* - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM) != NULL) { - config_req_rlc_um_asn1( - ctxt_pP, - SRB_FLAG_YES, - MBMS_FLAG_NO, - UNUSED_PARAM_MBMS_SESSION_ID, - UNUSED_PARAM_MBMS_SERVICE_ID, - NULL, // TO DO DEFAULT CONFIG - NULL, // TO DO DEFAULT CONFIG - rb_id, lc_id); - } else { - LOG_D(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %ld \n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_id); - } - */ - break; - - default: - ; - } - } - } - } - - if (drb2add_listP != NULL) { - for (cnt=0; cnt<drb2add_listP->list.count; cnt++) { - drb_toaddmod_p = drb2add_listP->list.array[cnt]; - drb_id = drb_toaddmod_p->drb_Identity; - - if (drb_toaddmod_p->logicalChannelIdentity) { - lc_id = *drb_toaddmod_p->logicalChannelIdentity; - } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT" logicalChannelIdentity is missing from drb-ToAddMod information element!\n", PROTOCOL_CTXT_ARGS(ctxt_pP)); - continue; - } - - if (lc_id == 1 || lc_id == 2) { - LOG_E(RLC, PROTOCOL_CTXT_FMT" logicalChannelIdentity = %d is invalid in RRC message when adding DRB!\n", PROTOCOL_CTXT_ARGS(ctxt_pP), lc_id); - continue; - } - - LOG_D(RLC, "Adding DRB %ld, lc_id %d\n",drb_id,lc_id); - - if (drb_toaddmod_p->rlc_Config) { - switch (drb_toaddmod_p->rlc_Config->present) { - case LTE_RLC_Config_PR_NOTHING: - break; - - case LTE_RLC_Config_PR_am: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_AM,0, 0 ) != NULL) { - config_req_rlc_am_asn1 ( - ctxt_pP, - SRB_FLAG_NO, - &drb_toaddmod_p->rlc_Config->choice.am, - drb_id, lc_id); - } - - break; - - case LTE_RLC_Config_PR_um_Bi_Directional: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_UM,sourceL2Id,destinationL2Id) != NULL) { - config_req_rlc_um_asn1( - ctxt_pP, - SRB_FLAG_NO, - MBMS_FLAG_NO, - UNUSED_PARAM_MBMS_SESSION_ID, - UNUSED_PARAM_MBMS_SERVICE_ID, - &drb_toaddmod_p->rlc_Config->choice.um_Bi_Directional.ul_UM_RLC, - &drb_toaddmod_p->rlc_Config->choice.um_Bi_Directional.dl_UM_RLC, - drb_id, lc_id, - sourceL2Id, - destinationL2Id - ); - } - - break; - - case LTE_RLC_Config_PR_um_Uni_Directional_UL: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_UM,0,0) != NULL) { - config_req_rlc_um_asn1( - ctxt_pP, - SRB_FLAG_NO, - MBMS_FLAG_NO, - UNUSED_PARAM_MBMS_SESSION_ID, - UNUSED_PARAM_MBMS_SERVICE_ID, - &drb_toaddmod_p->rlc_Config->choice.um_Uni_Directional_UL.ul_UM_RLC, - NULL, - drb_id, lc_id,0, 0 - ); - } - - break; - - case LTE_RLC_Config_PR_um_Uni_Directional_DL: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_UM,0,0 ) != NULL) { - config_req_rlc_um_asn1( - ctxt_pP, - SRB_FLAG_NO, - MBMS_FLAG_NO, - UNUSED_PARAM_MBMS_SESSION_ID, - UNUSED_PARAM_MBMS_SERVICE_ID, - NULL, - &drb_toaddmod_p->rlc_Config->choice.um_Uni_Directional_DL.dl_UM_RLC, - drb_id, lc_id,0, 0 - ); - } - - break; - - default: - LOG_W(RLC, PROTOCOL_CTXT_FMT"[RB %ld] unknown drb_toaddmod_p->rlc_Config->present \n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - drb_id); - } - } - } - } - - if (drb2release_listP != NULL) { - for (cnt=0; cnt<drb2release_listP->list.count; cnt++) { - pdrb_id = drb2release_listP->list.array[cnt]; - rrc_rlc_remove_rlc( - ctxt_pP, - SRB_FLAG_NO, - MBMS_FLAG_NO, - *pdrb_id); - } - } - - if (pmch_InfoList_r9_pP != NULL) { - for (i=0; i<pmch_InfoList_r9_pP->list.count; i++) { - mbms_SessionInfoList_r9_p = &(pmch_InfoList_r9_pP->list.array[i]->mbms_SessionInfoList_r9); - - for (j=0; j<mbms_SessionInfoList_r9_p->list.count; j++) { - MBMS_SessionInfo_p = mbms_SessionInfoList_r9_p->list.array[j]; - - if (0/*MBMS_SessionInfo_p->sessionId_r9*/) - mbms_session_id = MBMS_SessionInfo_p->sessionId_r9->buf[0]; - else - mbms_session_id = MBMS_SessionInfo_p->logicalChannelIdentity_r9; - - lc_id = mbms_session_id; - mbms_service_id = MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[2]; //serviceId is 3-octet string - // mbms_service_id = j; - - // can set the mch_id = i - if (ctxt_pP->enb_flag) { - rb_id = (mbms_service_id * LTE_maxSessionPerPMCH ) + mbms_session_id;//+ (LTE_maxDRB + 3) * MAX_MOBILES_PER_ENB; // 1 - rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lc_id].service_id = mbms_service_id; - rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lc_id].session_id = mbms_session_id; - rlc_mbms_enb_set_lcid_by_rb_id(ctxt_pP->module_id,rb_id,lc_id); - } else { - rb_id = (mbms_service_id * LTE_maxSessionPerPMCH ) + mbms_session_id; // + (LTE_maxDRB + 3); // 15 - rlc_mbms_lcid2service_session_id_ue[ctxt_pP->module_id][lc_id].service_id = mbms_service_id; - rlc_mbms_lcid2service_session_id_ue[ctxt_pP->module_id][lc_id].session_id = mbms_session_id; - rlc_mbms_ue_set_lcid_by_rb_id(ctxt_pP->module_id,rb_id,lc_id); - } - - key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->module_id, ctxt_pP->enb_flag, mbms_service_id, mbms_session_id); - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - if (h_rc == HASH_TABLE_KEY_NOT_EXISTS) { - rlc_union_p = rrc_rlc_add_rlc ( - ctxt_pP, - SRB_FLAG_NO, - MBMS_FLAG_YES, - rb_id, - lc_id, - RLC_MODE_UM, 0, 0); - - //AssertFatal(rlc_union_p != NULL, "ADD MBMS RLC UM FAILED"); - if(rlc_union_p == NULL) { - LOG_E(RLC, "ADD MBMS RLC UM FAILED\n"); - } - } - - LOG_I(RLC, PROTOCOL_CTXT_FMT" CONFIG REQ MBMS ASN1 LC ID %u RB ID %ld SESSION ID %u SERVICE ID %u\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - lc_id, - rb_id, - mbms_session_id, - mbms_service_id - ); - dl_um_rlc.sn_FieldLength = LTE_SN_FieldLength_size5; - dl_um_rlc.t_Reordering = LTE_T_Reordering_ms0; - config_req_rlc_um_asn1 ( - ctxt_pP, - SRB_FLAG_NO, - MBMS_FLAG_YES, - mbms_session_id, - mbms_service_id, - NULL, - &dl_um_rlc, - rb_id, lc_id,0, 0 - ); - } - } - } - - LOG_D(RLC, PROTOCOL_CTXT_FMT" CONFIG REQ ASN1 END \n", - PROTOCOL_CTXT_ARGS(ctxt_pP)); - return RLC_OP_STATUS_OK; -} -//----------------------------------------------------------------------------- -void -rb_free_rlc_union ( - void *rlcu_pP) { - //----------------------------------------------------------------------------- - rlc_union_t *rlcu_p; - - if (rlcu_pP) { - rlcu_p = (rlc_union_t *)(rlcu_pP); - LOG_D(RLC,"%s %p \n",__FUNCTION__,rlcu_pP); - - switch (rlcu_p->mode) { - case RLC_MODE_AM: - rlc_am_cleanup(&rlcu_p->rlc.am); - break; - - case RLC_MODE_UM: - rlc_um_cleanup(&rlcu_p->rlc.um); - break; - - case RLC_MODE_TM: - rlc_tm_cleanup(&rlcu_p->rlc.tm); - break; - - default: - LOG_W(RLC, - "%s %p unknown RLC type\n", - __FUNCTION__, - rlcu_pP); - break; - } - } -} - -//----------------------------------------------------------------------------- -rlc_op_status_t rrc_rlc_remove_ue ( - const protocol_ctxt_t *const ctxt_pP) { - //----------------------------------------------------------------------------- - rb_id_t rb_id; - - for (rb_id = 1; rb_id <= 2; rb_id++) { - rrc_rlc_remove_rlc(ctxt_pP, - SRB_FLAG_YES, - MBMS_FLAG_NO, - rb_id); - } - - for (rb_id = 1; rb_id <= LTE_maxDRB; rb_id++) { - rrc_rlc_remove_rlc(ctxt_pP, - SRB_FLAG_NO, - MBMS_FLAG_NO, - rb_id); - } - - return RLC_OP_STATUS_OK; -} - -//----------------------------------------------------------------------------- -rlc_op_status_t rrc_rlc_remove_rlc ( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_idP) { - //----------------------------------------------------------------------------- - logical_chan_id_t lcid = 0; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - hash_key_t key_lcid = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_lcid_rc; - rlc_union_t *rlc_union_p = NULL; - rlc_mbms_id_t *mbms_id_p = NULL; - /* for no gcc warnings */ - (void)lcid; - - if (MBMS_flagP == true) { - if (ctxt_pP->enb_flag) { - lcid = rlc_mbms_enb_get_lcid_by_rb_id(ctxt_pP->module_id,rb_idP); - mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid]; - rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].service_id = 0; - rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].session_id = 0; - rlc_mbms_rbid2lcid_ue[ctxt_pP->module_id][rb_idP] = RLC_LC_UNALLOCATED; - } else { - lcid = rlc_mbms_ue_get_lcid_by_rb_id(ctxt_pP->module_id,rb_idP); - mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ctxt_pP->module_id][lcid]; - rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].service_id = 0; - rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].session_id = 0; - rlc_mbms_rbid2lcid_ue[ctxt_pP->module_id][rb_idP] = RLC_LC_UNALLOCATED; - } - - key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_id_p->service_id, mbms_id_p->session_id); - } else { - key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); - } - - //AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); - if(rb_idP >= NB_RB_MAX) { - LOG_E(RLC, "RB id is too high (%ld/%d)!\n", rb_idP, NB_RB_MAX); - return RLC_OP_STATUS_BAD_PARAMETER; - } - - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - if (h_rc == HASH_TABLE_OK) { - // also remove the hash-key created by LC-id - switch (rlc_union_p->mode) { - case RLC_MODE_AM: - lcid = rlc_union_p->rlc.am.channel_id; - break; - - case RLC_MODE_UM: - lcid = rlc_union_p->rlc.um.channel_id; - break; - - case RLC_MODE_TM: - lcid = rlc_union_p->rlc.tm.channel_id; - break; - - default: - LOG_E(RLC, PROTOCOL_CTXT_FMT"[%s %ld] RLC mode is unknown!\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - (srb_flagP) ? "SRB" : "DRB", - rb_idP); - } - - key_lcid = RLC_COLL_KEY_LCID_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, lcid, srb_flagP); - h_lcid_rc = hashtable_get(rlc_coll_p, key_lcid, (void **)&rlc_union_p); - } else { - h_lcid_rc = HASH_TABLE_KEY_NOT_EXISTS; - } - - if ((h_rc == HASH_TABLE_OK) && (h_lcid_rc == HASH_TABLE_OK)) { - h_lcid_rc = hashtable_remove(rlc_coll_p, key_lcid); - h_rc = hashtable_remove(rlc_coll_p, key); - LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %ld LCID %d] RELEASED %s\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - (srb_flagP) ? "SRB" : "DRB", - rb_idP, lcid, - (srb_flagP) ? "SRB" : "DRB"); - } else if ((h_rc == HASH_TABLE_KEY_NOT_EXISTS) || (h_lcid_rc == HASH_TABLE_KEY_NOT_EXISTS)) { - LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %ld LCID %d] RELEASE : RLC NOT FOUND %s, by RB-ID=%d, by LC-ID=%d\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - (srb_flagP) ? "SRB" : "DRB", - rb_idP, lcid, - (srb_flagP) ? "SRB" : "DRB", - h_rc, h_lcid_rc); - } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT"[%s %ld LCID %d] RELEASE : INTERNAL ERROR %s\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - (srb_flagP) ? "SRB" : "DRB", - rb_idP, lcid, - (srb_flagP) ? "SRB" : "DRB"); - } - - return RLC_OP_STATUS_OK; -} -//----------------------------------------------------------------------------- -rlc_union_t *rrc_rlc_add_rlc ( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_idP, - const logical_chan_id_t chan_idP, - const rlc_mode_t rlc_modeP, - const uint32_t sourceL2Id, - const uint32_t destinationL2Id -) { - //----------------------------------------------------------------------------- - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - hash_key_t key_lcid = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_lcid_rc; - rlc_union_t *rlc_union_p = NULL; - rlc_mbms_id_t *mbms_id_p = NULL; - logical_chan_id_t lcid = 0; - - if (MBMS_flagP == false) { - //AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); - //AssertFatal (chan_idP < RLC_MAX_LC, "LC id is too high (%u/%d)!\n", chan_idP, RLC_MAX_LC); - if(rb_idP >= NB_RB_MAX) { - LOG_E(RLC, "RB id is too high (%ld/%d)!\n", rb_idP, NB_RB_MAX); - return NULL; - } - - if(chan_idP >= RLC_MAX_LC) { - LOG_E(RLC, "LC id is too high (%u/%d)!\n", chan_idP, RLC_MAX_LC); - return NULL; - } - } - - if (MBMS_flagP == true) { - if (ctxt_pP->enb_flag) { - lcid = rlc_mbms_enb_get_lcid_by_rb_id(ctxt_pP->module_id,rb_idP); - mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid]; - //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].service_id = 0; - //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].session_id = 0; - //LG 2014-04-15rlc_mbms_rbid2lcid_eNB[ctxt_pP->module_id][rb_idP] = RLC_LC_UNALLOCATED; - } else { - lcid = rlc_mbms_ue_get_lcid_by_rb_id(ctxt_pP->module_id,rb_idP); - mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ctxt_pP->module_id][lcid]; - //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].service_id = 0; - //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][lcid].session_id = 0; - //LG 2014-04-15rlc_mbms_rbid2lcid_ue[ctxt_pP->module_id][rb_idP] = RLC_LC_UNALLOCATED; - } - - key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_id_p->service_id, mbms_id_p->session_id); - } else { - if ((sourceL2Id > 0) && (destinationL2Id > 0) ) { - key = RLC_COLL_KEY_SOURCE_DEST_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, sourceL2Id, destinationL2Id, srb_flagP); - key_lcid = RLC_COLL_KEY_LCID_SOURCE_DEST_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, chan_idP, sourceL2Id, destinationL2Id, srb_flagP); - } else { - key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); - key_lcid = RLC_COLL_KEY_LCID_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, chan_idP, srb_flagP); - } - } - - h_rc = hashtable_get(rlc_coll_p, key, (void **)&rlc_union_p); - - if (h_rc == HASH_TABLE_OK) { - LOG_W(RLC, PROTOCOL_CTXT_FMT"[%s %ld] rrc_rlc_add_rlc , already exist %s\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - (srb_flagP) ? "SRB" : "DRB", - rb_idP, - (srb_flagP) ? "SRB" : "DRB"); - - //AssertFatal(rlc_union_p->mode == rlc_modeP, "Error rrc_rlc_add_rlc , already exist but RLC mode differ"); - if(rlc_union_p->mode != rlc_modeP) { - LOG_E(RLC, "Error rrc_rlc_add_rlc , already exist but RLC mode differ\n"); - return NULL; - } - - return rlc_union_p; - } else if (h_rc == HASH_TABLE_KEY_NOT_EXISTS) { - rlc_union_p = calloc(1, sizeof(rlc_union_t)); - h_rc = hashtable_insert(rlc_coll_p, key, rlc_union_p); - if(MBMS_flagP != true) - h_lcid_rc = hashtable_insert(rlc_coll_p, key_lcid, rlc_union_p); - - if ((h_rc == HASH_TABLE_OK) && (h_lcid_rc == HASH_TABLE_OK)) { - if (MBMS_flagP == true) { - LOG_I(RLC, PROTOCOL_CTXT_FMT" RLC service id %u session id %u rrc_rlc_add_rlc\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - mbms_id_p->service_id, - mbms_id_p->session_id); - } else { - LOG_I(RLC, PROTOCOL_CTXT_FMT" [%s %ld] rrc_rlc_add_rlc %s\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - (srb_flagP) ? "SRB" : "DRB", - rb_idP, - (srb_flagP) ? "SRB" : "DRB"); - } - - rlc_union_p->mode = rlc_modeP; - return rlc_union_p; - } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT"[%s %ld] rrc_rlc_add_rlc FAILED %s (add by RB_id=%d; add by LC_id=%d)\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - (srb_flagP) ? "SRB" : "DRB", - rb_idP, - (srb_flagP) ? "SRB" : "DRB", - h_rc, h_lcid_rc); - free(rlc_union_p); - rlc_union_p = NULL; - return NULL; - } - } else { - LOG_E(RLC, PROTOCOL_CTXT_FMT"[%s %ld] rrc_rlc_add_rlc , INTERNAL ERROR %s\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - (srb_flagP) ? "SRB" : "DRB", - rb_idP, - (srb_flagP) ? "SRB" : "DRB"); - } - - return NULL; -} -//----------------------------------------------------------------------------- -rlc_op_status_t rrc_rlc_config_req ( - const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t mbms_flagP, - const config_action_t actionP, - const rb_id_t rb_idP, - const rlc_info_t rlc_infoP) { - //----------------------------------------------------------------------------- - //rlc_op_status_t status; - LOG_D(RLC, PROTOCOL_CTXT_FMT" CONFIG_REQ for RAB %ld\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_idP); - - //AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); - if(rb_idP >= NB_RB_MAX) { - LOG_E(RLC, "RB id is too high (%ld/%d)!\n", rb_idP, NB_RB_MAX); - return RLC_OP_STATUS_BAD_PARAMETER; - } - - switch (actionP) { - case CONFIG_ACTION_ADD: - if (rrc_rlc_add_rlc(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, rb_idP, rlc_infoP.rlc_mode,0, 0 ) != NULL) { - return RLC_OP_STATUS_INTERNAL_ERROR; - } - - // no break, fall to next case - case CONFIG_ACTION_MODIFY: - switch (rlc_infoP.rlc_mode) { - case RLC_MODE_AM: - LOG_I(RLC, PROTOCOL_CTXT_FMT"[RB %ld] MODIFY RB AM\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_idP); - config_req_rlc_am( - ctxt_pP, - srb_flagP, - &rlc_infoP.rlc.rlc_am_info, - rb_idP, rb_idP); - break; - - case RLC_MODE_UM: - LOG_I(RLC, PROTOCOL_CTXT_FMT"[RB %ld] MODIFY RB UM\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_idP); - config_req_rlc_um( - ctxt_pP, - srb_flagP, - &rlc_infoP.rlc.rlc_um_info, - rb_idP, rb_idP); - break; - - case RLC_MODE_TM: - LOG_I(RLC, PROTOCOL_CTXT_FMT"[RB %ld] MODIFY RB TM\n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_idP); - config_req_rlc_tm( - ctxt_pP, - srb_flagP, - &rlc_infoP.rlc.rlc_tm_info, - rb_idP, rb_idP); - break; - - default: - return RLC_OP_STATUS_BAD_PARAMETER; - } - - break; - - case CONFIG_ACTION_REMOVE: - return rrc_rlc_remove_rlc(ctxt_pP, srb_flagP, mbms_flagP, rb_idP); - break; - - default: - return RLC_OP_STATUS_BAD_PARAMETER; - } - - return RLC_OP_STATUS_OK; -} -//----------------------------------------------------------------------------- -rlc_op_status_t rrc_rlc_data_req ( - const protocol_ctxt_t *const ctxt_pP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_idP, - const mui_t muiP, - const confirm_t confirmP, - const sdu_size_t sdu_sizeP, - char *sduP) { - //----------------------------------------------------------------------------- - mem_block_t *sdu; - sdu = get_free_mem_block(sdu_sizeP, __func__); - - if (sdu != NULL) { - memcpy (sdu->data, sduP, sdu_sizeP); - return rlc_data_req(ctxt_pP, SRB_FLAG_YES, MBMS_flagP, rb_idP, muiP, confirmP, sdu_sizeP, sdu,NULL, NULL ); - } else { - return RLC_OP_STATUS_INTERNAL_ERROR; - } -} - -//----------------------------------------------------------------------------- -void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_data_conf_cb_t rrc_data_confP) { - //----------------------------------------------------------------------------- - rlc_rrc_data_ind = rrc_data_indP; - rlc_rrc_data_conf = rrc_data_confP; -} - diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index c0046a7713df04b5e49751cb698b14071525453f..781f2007d4d02964fbc5660e034efc366973c02e 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -1109,7 +1109,6 @@ void nr_DRB_preconfiguration(ue_id_t crntiMaybeUEid) (NR_SRB_ToAddModList_t *) NULL, rbconfig->drb_ToAddModList, rbconfig->drb_ToReleaseList, - (LTE_PMCH_InfoList_r9_t *) NULL, Rlc_Bearer_ToAdd_list); LOG_D(PDCP, "%s:%d: done RRC PDCP/RLC ASN1 request for UE ID/RNTI %ld\n", __FUNCTION__, __LINE__, ctxt.rntiMaybeUEid); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index d17e53cce49f2d4f32d127540128b394b0387439..29aab4ab5aee79a0a0929402622eb50c145d8f70 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -957,7 +957,6 @@ rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt const NR_SRB_ToAddModList_t * const srb2add_listP, const NR_DRB_ToAddModList_t * const drb2add_listP, const NR_DRB_ToReleaseList_t * const drb2release_listP, - const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list) { int rnti = ctxt_pP->rntiMaybeUEid; @@ -973,11 +972,6 @@ rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt exit(1); } - if (pmch_InfoList_r9_pP != NULL) { - LOG_E(RLC, "%s: pmch_InfoList_r9_pP not handled\n", __FUNCTION__); - exit(1); - } - if (drb2release_listP != NULL) { LOG_E(RLC, "%s:%d:%s: TODO\n", __FILE__, __LINE__, __FUNCTION__); //exit(1); @@ -1084,8 +1078,7 @@ rlc_op_status_t rrc_rlc_config_req ( const srb_flag_t srb_flagP, const MBMS_flag_t mbms_flagP, const config_action_t actionP, - const rb_id_t rb_idP, - const rlc_info_t rlc_infoP) + const rb_id_t rb_idP) { nr_rlc_ue_t *ue; int i; diff --git a/openair2/LAYER2/rlc_v2/rlc_oai_api.c b/openair2/LAYER2/rlc_v2/rlc_oai_api.c index 7e9a33e087723858300a2973232d5e38c676bab1..87c922246824a4b73c59a770ae256dc4c14e631d 100644 --- a/openair2/LAYER2/rlc_v2/rlc_oai_api.c +++ b/openair2/LAYER2/rlc_v2/rlc_oai_api.c @@ -954,8 +954,7 @@ rlc_op_status_t rrc_rlc_config_req ( const srb_flag_t srb_flagP, const MBMS_flag_t mbms_flagP, const config_action_t actionP, - const rb_id_t rb_idP, - const rlc_info_t rlc_infoP) + const rb_id_t rb_idP) { rlc_ue_t *ue; int i; diff --git a/openair2/RRC/LTE/extern_NB_IoT.h b/openair2/RRC/LTE/extern_NB_IoT.h index f240e8b2159381376a6888a31665fd83a5f29229..24934f4bf18b356e00cfca537db78b7ed3f9d794 100644 --- a/openair2/RRC/LTE/extern_NB_IoT.h +++ b/openair2/RRC/LTE/extern_NB_IoT.h @@ -46,7 +46,6 @@ extern UE_RRC_INST_NB_IoT *UE_rrc_inst_NB_IoT; extern eNB_RRC_INST_NB_IoT *eNB_rrc_inst_NB_IoT; extern PHY_Config_NB_IoT_t *config_INFO; -extern rlc_info_t Rlc_info_am_NB_IoT,Rlc_info_am_config_NB_IoT; extern uint8_t DRB2LCHAN_NB_IoT[2]; extern LTE_LogicalChannelConfig_NB_r13_t SRB1bis_logicalChannelConfig_defaultValue_NB_IoT; extern LTE_LogicalChannelConfig_NB_r13_t SRB1_logicalChannelConfig_defaultValue_NB_IoT; diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index 327099c1c9ccef8c51b8e0e71aecf4739d50d344..ca051194dbc0dff453420f61747d2f6dceb4ec52 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -522,8 +522,7 @@ rrc_t310_expiration( SRB_FLAG_YES, MBMS_FLAG_NO, CONFIG_ACTION_REMOVE, - UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id, - Rlc_info_um); + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id); UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Active = 0; UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].StatusSrb = IDLE; UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Next_check_frame = 0; @@ -710,7 +709,7 @@ rrc_ue_establish_srb1( // memcpy(&UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Srb_info.Lchan_desc[1],&DCCH_LCHAN_DESC,LCHAN_DESC_SIZE); LOG_I(RRC,"[UE %d], CONFIG_SRB1 %d corresponding to eNB_index %d\n", ue_mod_idP,DCCH,eNB_index); //rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, lchan_id,UNDEF_SECURITY_MODE); - // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,lchan_id,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); + // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,lchan_id,SIGNALLING_RADIO_BEARER); // UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size=DEFAULT_MEAS_IND_SIZE+1; return(0); } @@ -734,7 +733,7 @@ rrc_ue_establish_srb2( // memcpy(&UE_rrc_inst[ue_mod_idP].Srb2[eNB_index].Srb_info.Lchan_desc[1],&DCCH_LCHAN_DESC,LCHAN_DESC_SIZE); LOG_I(RRC,"[UE %d], CONFIG_SRB2 %d corresponding to eNB_index %d\n",ue_mod_idP,DCCH1,eNB_index); //rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, lchan_id, UNDEF_SECURITY_MODE); - // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,lchan_id,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); + // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,lchan_id,SIGNALLING_RADIO_BEARER); // UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size=DEFAULT_MEAS_IND_SIZE+1; return(0); } @@ -2124,11 +2123,11 @@ rrc_ue_process_mobilityControlInfo( //Removing SRB1 and SRB2 and DRB0 LOG_I(RRC,"[UE %d] : Update needed for rrc_pdcp_config_req (deprecated) and rrc_rlc_config_req commands(deprecated)\n", ctxt_pP->module_id); rrc_pdcp_config_req (ctxt_pP, SRB_FLAG_YES, CONFIG_ACTION_REMOVE, DCCH,UNDEF_SECURITY_MODE); - rrc_rlc_config_req(ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, CONFIG_ACTION_REMOVE,ctxt_pP->module_id+DCCH,Rlc_info_am_config); + rrc_rlc_config_req(ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, CONFIG_ACTION_REMOVE,ctxt_pP->module_id+DCCH); rrc_pdcp_config_req (ctxt_pP, SRB_FLAG_YES, CONFIG_ACTION_REMOVE, DCCH1,UNDEF_SECURITY_MODE); - rrc_rlc_config_req(ctxt_pP, SRB_FLAG_YES,CONFIG_ACTION_REMOVE, MBMS_FLAG_NO,ctxt_pP->module_id+DCCH1,Rlc_info_am_config); + rrc_rlc_config_req(ctxt_pP, SRB_FLAG_YES,CONFIG_ACTION_REMOVE, MBMS_FLAG_NO,ctxt_pP->module_id+DCCH1); rrc_pdcp_config_req (ctxt_pP, SRB_FLAG_NO, CONFIG_ACTION_REMOVE, DTCH,UNDEF_SECURITY_MODE); - rrc_rlc_config_req(ctxt_pP, SRB_FLAG_NO,CONFIG_ACTION_REMOVE, MBMS_FLAG_NO,ctxt_pP->module_id+DTCH,Rlc_info_um); + rrc_rlc_config_req(ctxt_pP, SRB_FLAG_NO,CONFIG_ACTION_REMOVE, MBMS_FLAG_NO,ctxt_pP->module_id+DTCH); //Synchronisation to DL of target cell LOG_I(RRC, "HO: Reset PDCP and RLC for configured RBs.. \n[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB2 eNB %d) --->][MAC_UE][MOD %02d][]\n", @@ -2168,9 +2167,9 @@ rrc_ue_process_mobilityControlInfo( // rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, ue_mod_idP+DCCH1); // rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, ue_mod_idP+DTCH); // Re-establish RLC for all RBs that are established - // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,ue_mod_idP+DCCH,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); - // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,ue_mod_idP+DCCH1,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); - // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,ue_mod_idP+DTCH,RADIO_ACCESS_BEARER,Rlc_info_um); + // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,ue_mod_idP+DCCH,SIGNALLING_RADIO_BEARER); + // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,ue_mod_idP+DCCH1,SIGNALLING_RADIO_BEARER); + // rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,ue_mod_idP+DTCH,RADIO_ACCESS_BEARER); UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_SI_RECEIVED; } diff --git a/openair2/RRC/LTE/rrc_common.c b/openair2/RRC/LTE/rrc_common.c index c40d0ff76635784f1c42a57a050d7b411788446e..be7a4048f9f932e30613e80ef110c2b5510cc1fc 100644 --- a/openair2/RRC/LTE/rrc_common.c +++ b/openair2/RRC/LTE/rrc_common.c @@ -66,18 +66,6 @@ rrc_init_global_param( DTCH_UL_LCHAN_DESC.transport_block_size = 52; DTCH_UL_LCHAN_DESC.max_transport_blocks = 20; DTCH_UL_LCHAN_DESC.Delay_class = 1; - Rlc_info_um.rlc_mode = RLC_MODE_UM; - Rlc_info_um.rlc.rlc_um_info.timer_reordering = 5; - Rlc_info_um.rlc.rlc_um_info.sn_field_length = 10; - Rlc_info_um.rlc.rlc_um_info.is_mXch = 0; - //Rlc_info_um.rlc.rlc_um_info.sdu_discard_mode=16; - Rlc_info_am_config.rlc_mode = RLC_MODE_AM; - Rlc_info_am_config.rlc.rlc_am_info.max_retx_threshold = 50; - Rlc_info_am_config.rlc.rlc_am_info.poll_pdu = 8; - Rlc_info_am_config.rlc.rlc_am_info.poll_byte = 1000; - Rlc_info_am_config.rlc.rlc_am_info.t_poll_retransmit = 15; - Rlc_info_am_config.rlc.rlc_am_info.t_reordering = 50; - Rlc_info_am_config.rlc.rlc_am_info.t_status_prohibit = 10; return 0; } diff --git a/openair2/RRC/LTE/rrc_extern.h b/openair2/RRC/LTE/rrc_extern.h index 14de4d8dcccd2bb8c8ea1fc0865c6533639fbc42..644512a686f5a09271e9c60d22651cfdfb088634 100644 --- a/openair2/RRC/LTE/rrc_extern.h +++ b/openair2/RRC/LTE/rrc_extern.h @@ -48,8 +48,6 @@ extern int NB_UE_INST; extern void* bigphys_malloc(int); -//CONSTANTS -extern rlc_info_t Rlc_info_um,Rlc_info_am_config; //uint8_t RACH_TIME_ALLOC; extern uint16_t RACH_FREQ_ALLOC; //uint8_t NB_RACH; diff --git a/openair2/RRC/LTE/rrc_vars.h b/openair2/RRC/LTE/rrc_vars.h index f0495a7649d299b4debbe5c82c878591c7655182..693459f2ff50d3627e867b64614e738c532ae9f7 100644 --- a/openair2/RRC/LTE/rrc_vars.h +++ b/openair2/RRC/LTE/rrc_vars.h @@ -78,7 +78,6 @@ LTE_LogicalChannelConfig_t SRB2_logicalChannelConfig_defaultValue = {ul_Specific }; //CONSTANTS -rlc_info_t Rlc_info_um,Rlc_info_am_config; uint16_t RACH_FREQ_ALLOC; //uint8_t NB_RACH; LCHAN_DESC BCCH_LCHAN_DESC,CCCH_LCHAN_DESC,DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC; diff --git a/openair2/RRC/NR/nr_rrc_common.c b/openair2/RRC/NR/nr_rrc_common.c index daa9663ca8972db7d4ecc7b5641e9f0c82bfee02..828e39246002b908f78b0246b7c7e8dc68312b25 100644 --- a/openair2/RRC/NR/nr_rrc_common.c +++ b/openair2/RRC/NR/nr_rrc_common.c @@ -63,20 +63,6 @@ int rrc_init_nr_global_param(void){ DTCH_UL_LCHAN_DESC.max_transport_blocks = 20; DTCH_UL_LCHAN_DESC.Delay_class = 1; - Rlc_info_um.rlc_mode = RLC_MODE_UM; - Rlc_info_um.rlc.rlc_um_info.timer_reordering = 5; - Rlc_info_um.rlc.rlc_um_info.sn_field_length = 10; - Rlc_info_um.rlc.rlc_um_info.is_mXch = 0; - //Rlc_info_um.rlc.rlc_um_info.sdu_discard_mode=16; - - Rlc_info_am_config.rlc_mode = RLC_MODE_AM; - Rlc_info_am_config.rlc.rlc_am_info.max_retx_threshold = 50; - Rlc_info_am_config.rlc.rlc_am_info.poll_pdu = 8; - Rlc_info_am_config.rlc.rlc_am_info.poll_byte = 1000; - Rlc_info_am_config.rlc.rlc_am_info.t_poll_retransmit = 15; - Rlc_info_am_config.rlc.rlc_am_info.t_reordering = 50; - Rlc_info_am_config.rlc.rlc_am_info.t_status_prohibit = 10; - return 0; } diff --git a/openair2/RRC/NR/nr_rrc_extern.h b/openair2/RRC/NR/nr_rrc_extern.h index 85faa6069749f904a38a8f88d962d12bb1b1c657..7283b25be0c4e08b4185248c55e16f25b3b833a0 100644 --- a/openair2/RRC/NR/nr_rrc_extern.h +++ b/openair2/RRC/NR/nr_rrc_extern.h @@ -51,8 +51,6 @@ extern int NB_UE_INST; extern void* bigphys_malloc(int); -//CONSTANTS -extern rlc_info_t Rlc_info_um,Rlc_info_am_config; //uint8_t RACH_TIME_ALLOC; extern uint16_t RACH_FREQ_ALLOC; //uint8_t NB_RACH; diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 57aee7a6b2b574b6f8f8f7a216242b6923325297..0d7e0e7f970b6c941da10bce8f4bcc466f795c2f 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -207,7 +207,6 @@ rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt const NR_SRB_ToAddModList_t * const srb2add_listP, const NR_DRB_ToAddModList_t * const drb2add_listP, const NR_DRB_ToReleaseList_t * const drb2release_listP, - const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); void nr_pdcp_add_srbs(eNB_flag_t enb_flag, ue_id_t rntiMaybeUEid, NR_SRB_ToAddModList_t *const srb2add_list, const uint8_t security_modeP, uint8_t *const kRRCenc, uint8_t *const kUPint); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 5a0a138c6679447a855903c6423112d6b83c68c3..b5a63cdf0db76c84d3354f37622fe19266b07f44 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -307,7 +307,6 @@ void apply_macrlc_config(gNB_RRC_INST *rrc, ue_context_pP->ue_context.SRB_configList, ue_context_pP->ue_context.DRB_configList, NULL, - NULL, get_softmodem_params()->sa ? cgc->rlc_BearerToAddModList : NULL); } @@ -1323,7 +1322,6 @@ rrc_gNB_process_RRCReconfigurationComplete( SRB_configList, // NULL, DRB_configList, DRB_Release_configList2, - NULL, get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); } @@ -1391,8 +1389,7 @@ rrc_gNB_process_RRCReconfigurationComplete( SRB_FLAG_NO, MBMS_FLAG_NO, CONFIG_ACTION_REMOVE, - nr_DRB2LCHAN[i], - Rlc_info_um);*/ + nr_DRB2LCHAN[i]);*/ } ue_context_pP->ue_context.DRB_active[drb_id] = 0; diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index a6ce1b4a554250bc568baf158b0896780e87c707..379e4d8bdc70f3afc37f96f8944f0a45e4a1fc1d 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -396,7 +396,6 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ get_softmodem_params()->sa ? ue_context_p->ue_context.rb_config->srb_ToAddModList : NULL, ue_context_p->ue_context.rb_config->drb_ToAddModList, ue_context_p->ue_context.rb_config->drb_ToReleaseList, - (LTE_PMCH_InfoList_r9_t *)NULL, ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList); LOG_D(RRC, "%s:%d: done RRC PDCP/RLC ASN1 request for UE rnti %lx\n", __FUNCTION__, __LINE__, ctxt.rntiMaybeUEid); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 93d459b3ed5722759dd9cbe329a0a53197cbe157..b09b09efb399d751d8e93f7be082a7153140b37a 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1974,7 +1974,6 @@ nr_rrc_ue_establish_srb2( radioBearerConfig->srb_ToAddModList, NULL, NULL, - NULL, NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList ); @@ -2069,7 +2068,7 @@ nr_rrc_ue_establish_srb2( kUPint, NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList); // Refresh DRBs - nr_rrc_rlc_config_asn1_req(ctxt_pP, NULL, radioBearerConfig->drb_ToAddModList, NULL, NULL, NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList); + nr_rrc_rlc_config_asn1_req(ctxt_pP, NULL, radioBearerConfig->drb_ToAddModList, NULL, NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList); } // drb_ToAddModList // if (radioBearerConfig->drb_ToReleaseList != NULL) { diff --git a/openair2/UTIL/LISTS/list.c b/openair2/UTIL/LISTS/list.c deleted file mode 100644 index 578833edba59b6b65df567846128f9637e7ba621..0000000000000000000000000000000000000000 --- a/openair2/UTIL/LISTS/list.c +++ /dev/null @@ -1,446 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file list.c -* \brief list management primimtives. It includes three implementations: (1) with mem_blocks, (2) standard list implementation (mem usage 314MB) (3) Linux Queue-based implementation (mem usage 394 MB) -* \author Navid Nikaein, Mohamed Said MOSLI BOUKSIAA, Lionel GAUTHIER -* \date 2012 - 2014 -* \version 0.5 -* @ingroup util -*/ - -#define LIST_C -#define NULL 0 - -#include "list.h" -#include <string.h> - -//----------------------------------------------------------------------------- -/* - * initialize list - */ -//----------------------------------------------------------------------------- -void -list_init (list_t * listP, char *nameP) -{ - //----------------------------------------------------------------------------- - if (nameP) { - strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR-1 ); - listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string - } - - listP->tail = NULL; - listP->head = NULL; - listP->nb_elements = 0; -} -//----------------------------------------------------------------------------- -void -list_free (list_t * listP) -{ - //----------------------------------------------------------------------------- - mem_block_t *le; - - while ((le = list_remove_head (listP))) { - free_mem_block (le, __func__); - } -} -//----------------------------------------------------------------------------- -mem_block_t * -list_get_head (list_t * listP) -{ - //----------------------------------------------------------------------------- - return listP->head; -} -//----------------------------------------------------------------------------- -/* - * remove an element from head of a list - * @param pointer on targeted list - * @return pointer on removed mem_block_t - */ -mem_block_t * -list_remove_head (list_t * listP) -{ - //----------------------------------------------------------------------------- - - // access optimisation - mem_block_t *head; - head = listP->head; - - // almost one element - if (head != NULL) { - listP->head = head->next; - listP->nb_elements = listP->nb_elements - 1; - - // if only one element, update tail - if (listP->head == NULL) { - listP->tail = NULL; - } else { - head->next = NULL; - } - } else { - //msg("[MEM_MGT][WARNING] remove_head_from_list(%s) no elements\n",listP->name); - } - - return head; -} - -//----------------------------------------------------------------------------- -mem_block_t * -list_remove_element (mem_block_t * elementP, list_t * listP) -{ - //----------------------------------------------------------------------------- - - // access optimisation; - mem_block_t *head; - - if (elementP != NULL) { - // test head - head = listP->head; - - if (listP->head == elementP) { - // almost one element - if (head != NULL) { - listP->head = head->next; - listP->nb_elements = listP->nb_elements - 1; - - // if only one element, update tail - if (listP->head == NULL) { - listP->tail = NULL; - } else { - head->next = NULL; - } - } - } else { - while (head) { - if (head->next == elementP) { - head->next = elementP->next; - listP->nb_elements = listP->nb_elements - 1; - - if (listP->tail == elementP) { - listP->tail = head; - } - - return elementP; - } else { - head = head->next; - } - } - } - } - - return elementP; -} - -//----------------------------------------------------------------------------- -/* - * add an element to the beginning of a list - * @param pointer on targeted list - * @return pointer on removed mem_block_t - */ -void -list_add_head (mem_block_t * elementP, list_t * listP) -{ - //----------------------------------------------------------------------------- - - // access optimisation; - mem_block_t *head; - - if (elementP != NULL) { - head = listP->head; - listP->nb_elements = listP->nb_elements + 1; - - // almost one element - if (head == NULL) { - listP->head = elementP; - listP->tail = elementP; - } else { - elementP->next = head; - listP->head = elementP; - } - } -} - -//----------------------------------------------------------------------------- -/* - * add an element to the end of a list - * @param pointer on targeted list - * @return pointer on removed mem_block_t - */ -void -list_add_tail_eurecom (mem_block_t * elementP, list_t * listP) -{ - mem_block_t *tail; - //----------------------------------------------------------------------------- - - if (elementP != NULL) { - // access optimisation - listP->nb_elements = listP->nb_elements + 1; - elementP->next = NULL; - tail = listP->tail; - - // almost one element - if (tail == NULL) { - listP->head = elementP; - } else { - tail->next = elementP; - } - - listP->tail = elementP; - } else { - //msg("[CNT_LIST][ERROR] add_cnt_tail() element NULL\n"); - } -} - -//----------------------------------------------------------------------------- -void -list_add_list (list_t * sublistP, list_t * listP) -{ - //----------------------------------------------------------------------------- - - if (sublistP) { - if (sublistP->head) { - // access optimisation - mem_block_t *tail; - - tail = listP->tail; - - // almost one element - if (tail == NULL) { - listP->head = sublistP->head; - } else { - tail->next = sublistP->head; - } - - listP->tail = sublistP->tail; - // clear sublist - sublistP->head = NULL; - sublistP->tail = NULL; - listP->nb_elements = listP->nb_elements + sublistP->nb_elements; - sublistP->nb_elements = 0; - } - } -} - -//----------------------------------------------------------------------------- -void -list_display (list_t * listP) -{ - //----------------------------------------------------------------------------- - - mem_block_t *cursor; - // unsigned short nb_elements = 0; - - // test lists - if (listP) { - cursor = listP->head; - - if (cursor) { - // almost one element - //msg ("Display list %s %p", listP->name, listP); - // while (cursor != NULL) { - // msg ("%d:", cursor->pool_id); - // msg ("\n"); - // cursor = cursor->next; - // nb_elements++; - //} - // msg (" found nb_elements %d nb_elements %d\n", nb_elements, listP->nb_elements); - } - } else { - //msg ("[SDU_MNGT][WARNING] display_cnt_list() : list is NULL\n"); - } -} -#ifndef LINUX_LIST -/*! \fn void push_front(struct list* z, double val) -* \brief this function pushes front new values in a predefined list. -* \param z is the predefined list -* val is the new value to be pushed inside the list -* \return -*/ -void -push_front(struct list* z, double val) -{ - - struct node* p = (struct node*) malloc(sizeof(struct node)); - - p->next = z->head; - p->val = val; - z->head = p; - - z->size++; - - return; - -} - -/*! \fn void initialize(struct list* z) -* \brief initialize a list structure. -* \param z is the list -* \return -*/ -void -initialize(struct list* z) -{ - z->head = NULL; - z->size = 0; - - return; -} - -/*! \fn void del(struct list* z) -* \brief delete a list structure. -* \param z is the list -* \return -*/ -void -del(struct list* z) -{ - struct node* cur; - struct node* x = z->head; - - while((x != NULL) && (z->size > 0)) { - cur = x; - x = x->next; - free(cur); - z->size--; - } - - z->head = NULL; - z->size = 0; - - return; -} -/*! \fn void totable(double* table, struct list* v) -* \brief convert a list structure to a table. -* \param table is a pointer to double table -* v is the list to be converted -* \return -*/ -void -totable(double* table, struct list* v) -{ - int i = 0; - - struct node* x = v->head; - - while(x) { - table[i] = x->val; - i++; - x = x->next; - } - - return; -} -/*! \fn int compare (const void * a, const void * b) -* \brief compare the value of two parameters -* \param a is a double, b is another double -* \return 1 if a>b, -0 if a<b -*/ -int compare (const void * a, const void * b) -{ - double x = *(double*)a; - double y = *(double*)b; - - return ( x > y ); -} -#else -// push an element to the head of the list -void push_front(struct list* z, double val) -{ - struct entry* p = (struct entry*) malloc(sizeof(struct entry)); - p->val = val; - - LIST_INSERT_HEAD(&z->head, p, entries); - z->size++; - - return; - -} - - -// initialization -void initialize(struct list* z) -{ - LIST_INIT(&z->head); - z->size = 0; - - return; -} - -// delete -void del(struct list* z) -{ - while (z->head.lh_first != NULL) { - free(z->head.lh_first); - LIST_REMOVE(z->head.lh_first, entries); - } - - z->size = 0; - - return; -} - -// convert the list to a table -void totable(double* table, struct list* v) -{ - int i = 0; - - struct entry* x; - - for (x = v->head.lh_first; x != NULL; x = x->entries.le_next) { - table[i] = x->val; - i++; - } - - return; -} - -int compare (const void * a, const void * b) -{ - double x = *(double*)a; - double y = *(double*)b; - - return ( x > y ); -} -#endif - -/*! \fn int32_t calculate_median(struct list *loc_list) -* \brief calculate the median of a list -* \param loc_list is the list -* \return the median value -*/ -int32_t calculate_median(struct list *loc_list) -{ - int32_t median = 0; - - if (loc_list->size > 0) { - double* table = (double*) malloc(loc_list->size * sizeof(double)); - totable(table, loc_list); - /// sort the table in ascending way - qsort (table, loc_list->size, sizeof(double), &compare); - /// median is the value at middle the sorted table - /// Q1 is the value at 1/4 the sorted table - /// Q3 is the value at 3/4 the sorted table - median = table[loc_list->size/2]; - free(table); - } - - return median; -} diff --git a/openair2/UTIL/LISTS/list.h b/openair2/UTIL/LISTS/list.h deleted file mode 100644 index 079c723ebf7739727d2f50c8ccda7672bd326949..0000000000000000000000000000000000000000 --- a/openair2/UTIL/LISTS/list.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - - -/*! \file pad_list.c -* \brief list management primimtives -* \author Mohamed Said MOSLI BOUKSIAA, Lionel GAUTHIER, Navid Nikaein -* \date 2012 - 2014 -* \version 0.5 -* @ingroup util -*/ - -/* - list.h - ------------------- - AUTHOR : Lionel GAUTHIER - COMPANY : EURECOM - EMAIL : Lionel.Gauthier@eurecom.fr - - ***************************************************************************/ -#ifndef __LIST_H__ -# define __LIST_H__ - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -#include<linux/types.h> -#include<stdlib.h> -#include<sys/queue.h> -#include <string.h> - - -#include "UTIL/MEM/mem_block.h" -#include <common/utils/assertions.h> - - -//----------------------------------------------------------------------------- -void list_init (list_t* , char *); -void list_free (list_t* listP); -mem_block_t* list_get_head (list_t*); -mem_block_t* list_remove_head (list_t* ); -mem_block_t* list_remove_element (mem_block_t*, list_t*); -void list_add_head (mem_block_t* , list_t* ); -void list_add_tail_eurecom (mem_block_t* , list_t* ); -void list_add_list (list_t* , list_t* ); -void list_display (list_t* ); -//----------------------------------------------------------------------------- -void list2_init (list2_t*, char*); -void list2_free (list2_t* ); -mem_block_t* list2_get_head (list2_t*); -mem_block_t* list2_get_tail (list2_t*); -mem_block_t* list2_remove_element (mem_block_t* , list2_t* ); -mem_block_t* list2_remove_head (list2_t* ); -mem_block_t* list2_remove_tail (list2_t* ); -void list2_add_head (mem_block_t* , list2_t* ); -void list2_add_tail (mem_block_t* , list2_t* ); -void list2_add_list (list2_t* , list2_t* ); -void list2_display (list2_t* ); -//----------------------------------------------------------------------------- -/* The following lists are used for sorting numbers */ -#ifndef LINUX_LIST -/*! \brief the node structure */ -struct node { - struct node* next; /*!< \brief is a node pointer */ - double val; /*!< \brief is a the value of a node pointer*/ -}; -//----------------------------------------------------------------------------- -/*! \brief the list structure */ -struct list { - struct node* head; /*!< \brief is a node pointer */ - ssize_t size; /*!< \brief is the list size*/ -}; -#else -//----------------------------------------------------------------------------- -struct entry { - double val; - LIST_ENTRY(entry) entries; -}; -//----------------------------------------------------------------------------- -struct list { - LIST_HEAD(listhead, entry) head; - ssize_t size; -}; -#endif -//----------------------------------------------------------------------------- -void push_front (struct list*, double); -void initialize (struct list*); -void del (struct list*); -void totable (double*, struct list*); -int compare (const void * a, const void * b); -int32_t calculate_median(struct list *loc_list); - - -typedef struct { - size_t size; - size_t mallocedSize; - size_t atomSize; - size_t increment; -} varArray_t; - -static inline varArray_t * initVarArray(size_t increment, size_t atomSize) { - varArray_t * tmp=(varArray_t *)malloc(sizeof(varArray_t)+increment*atomSize); - tmp->size=0; - tmp->atomSize=atomSize; - tmp->mallocedSize=increment; - tmp->increment=increment; - return(tmp); -} - -static inline void * dataArray(varArray_t * input) { - return input+1; -} - -static inline void appendVarArray(varArray_t ** inputPtr, void* data) { - varArray_t *input=*inputPtr; - if (input->size>=input->mallocedSize) { - input->mallocedSize+=input->increment; - *inputPtr=(varArray_t *)realloc(input,sizeof(varArray_t)+input->mallocedSize*input->atomSize); - AssertFatal(*inputPtr, "no memory left"); - input=*inputPtr; - } - memcpy((uint8_t*)(input+1)+input->atomSize*input->size++, data, input->atomSize); -} - -static inline void freeVarArray(varArray_t * input) { - free(input); -} - -#endif diff --git a/openair2/UTIL/LISTS/list2.c b/openair2/UTIL/LISTS/list2.c deleted file mode 100644 index d9aa1b6a90128e42adfb193cada81efe152f289f..0000000000000000000000000000000000000000 --- a/openair2/UTIL/LISTS/list2.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - - -/*! \file pad_list.c -* \brief list management primimtives -* \author Mohamed Said MOSLI BOUKSIAA, Lionel GAUTHIER, Navid Nikaein -* \date 2012 - 2014 -* \version 0.5 -* @ingroup util -*/ - -/*************************************************************************** - list2.c - description - ------------------- - ------------------- - AUTHOR : Lionel GAUTHIER - COMPANY : EURECOM - EMAIL : Lionel.Gauthier@eurecom.fr - ***************************************************************************/ -#define LIST2_C -#include "list.h" -#include "assertions.h" - -#include <string.h> - - -//----------------------------------------------------------------------------- -/* - * initialize list - */ -//----------------------------------------------------------------------------- -void -list2_init (list2_t * listP, char *nameP) -{ - //----------------------------------------------------------------------------- - if (nameP) { - strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR-1 ); - listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string - } - - listP->tail = NULL; - listP->head = NULL; - listP->nb_elements = 0; -} - -//----------------------------------------------------------------------------- -void -list2_free (list2_t * listP) -{ - //----------------------------------------------------------------------------- - - mem_block_t *le; - - while ((le = list2_remove_head (listP))) { - free_mem_block (le, __func__); - } -} - -//----------------------------------------------------------------------------- -/* - * remove an element from list - * @param pointer on targeted list - * @param mem_block_t to remove - * @return pointer on removed mem_block_t - */ -mem_block_t * -list2_remove_element (mem_block_t * elementP, list2_t * listP) -{ - //----------------------------------------------------------------------------- - - if (elementP != NULL) { - // head of list - if (elementP == listP->head) { - listP->head = elementP->next; - - if (listP->head == NULL) { - listP->tail = NULL; - } else { - elementP->next->previous = NULL; - elementP->next = NULL; - } - - // tail of the list - // note : case of 1 remaining element in the list has been treated above - } else if (elementP == listP->tail) { - // so several elements in the list - listP->tail = elementP->previous; - listP->tail->next = NULL; - elementP->previous = NULL; - // in the middle of the list, after a head element and before the tail element - } else { - // link element n-1 with element n+1 - elementP->previous->next = elementP->next; - elementP->next->previous = elementP->previous; - elementP->next = NULL; - elementP->previous = NULL; - } - - listP->nb_elements = listP->nb_elements - 1; - } - - return elementP; -} -//----------------------------------------------------------------------------- -mem_block_t * -list2_get_head (list2_t * listP) -{ - //----------------------------------------------------------------------------- - return listP->head; -} - -//----------------------------------------------------------------------------- -mem_block_t * -list2_get_tail (list2_t * listP) -{ - //----------------------------------------------------------------------------- - return listP->tail; -} - -//----------------------------------------------------------------------------- -/* - * remove an element from head of a list - * @param pointer on targeted list - * @return pointer on removed mem_block_t - */ -mem_block_t * -list2_remove_head (list2_t * listP) -{ - //----------------------------------------------------------------------------- - - // access optimisation - mem_block_t *head; - - head = listP->head; - - // almost one element - if (head != NULL) { - listP->head = head->next; - listP->nb_elements = listP->nb_elements - 1; - - // if only one element, update tail - if (listP->head == NULL) { - listP->tail = NULL; - } else { - listP->head->previous = NULL; - head->next = NULL; - } - } else { - //msg("[MEM_MGT][WARNING] remove_head_from_list(%s) no elements\n",listP->name); - } - - return head; -} - -//----------------------------------------------------------------------------- -/* - * remove an element from tail of a list - * @param pointer on targeted list - * @return pointer on removed mem_block_t - */ -mem_block_t * -list2_remove_tail (list2_t * listP) -{ - //----------------------------------------------------------------------------- - - // access optimisation; - mem_block_t *tail; - - - tail = listP->tail; - - // almost one element; - if (tail != NULL) { - listP->nb_elements = listP->nb_elements - 1; - - // if only one element, update head, tail; - if (listP->head == tail) { - listP->head = NULL; - listP->tail = NULL; - } else { - listP->tail = tail->previous; - tail->previous->next = NULL; - } - - tail->previous = NULL; - } else { - //msg("[MEM_MGT][WARNING] remove_head_from_list(%s) no elements\n",listP->name); - } - - return tail; -} - -//----------------------------------------------------------------------------- -/* - * add an element to the beginning of a list - * @param pointer on targeted list - * @return pointer on removed mem_block_t - */ -void -list2_add_head (mem_block_t * elementP, list2_t * listP) -{ - //----------------------------------------------------------------------------- - - // access optimisation; - mem_block_t *head; - - if (elementP != NULL) { - head = listP->head; - listP->nb_elements = listP->nb_elements + 1; - - // almost one element - if (head == NULL) { - elementP->previous = NULL; - elementP->next = NULL; - listP->head = elementP; - listP->tail = elementP; - } else { - elementP->next = head; - head->previous = elementP; - elementP->previous = NULL; - listP->head = elementP; - } - } -} - -//----------------------------------------------------------------------------- -/* - * add an element to the end of a list - * @param pointer on targeted list - * @return pointer on removed mem_block_t - */ -void -list2_add_tail (mem_block_t * elementP, list2_t * listP) -{ - mem_block_t *tail; - //----------------------------------------------------------------------------- - - if (elementP != NULL) { - // access optimisation - listP->nb_elements = listP->nb_elements + 1; - elementP->next = NULL; - tail = listP->tail; - - // almost one element - if (tail == NULL) { - elementP->previous = NULL; - listP->head = elementP; - } else { - tail->next = elementP; - elementP->previous = tail; - } - - listP->tail = elementP; - } -} - -//----------------------------------------------------------------------------- -void -list2_add_list (list2_t * sublistP, list2_t * listP) -{ - //----------------------------------------------------------------------------- - - if (sublistP) { - if (sublistP->head) { - // access optimisation - mem_block_t *tail; - - tail = listP->tail; - - // almost one element - if (tail == NULL) { - listP->head = sublistP->head; - } else { - tail->next = sublistP->head; - sublistP->head->previous = tail; - } - - listP->tail = sublistP->tail; - // clear sublist - sublistP->head = NULL; - sublistP->tail = NULL; - } - - listP->nb_elements = listP->nb_elements + sublistP->nb_elements; - } -} - -//----------------------------------------------------------------------------- -void -list2_display (list2_t * listP) -{ - //----------------------------------------------------------------------------- - /* - mem_block_t *cursor; - unsigned short nb_elements = 0; - //uint32_t nb_bytes; - // uint32_t index; - - // test lists - if (listP) { - cursor = listP->head; - if (cursor) { - // almost one element - msg ("Display list %s %p", listP->name, listP); - while (cursor != NULL) { - msg ("%d:", cursor->pool_id); - //nb_bytes = (( sdu_management*)(cursor->misc))->size; - // for (index=0; index < nb_bytes; index++) { - // msg("%02X.",cursor->data[index]); - // } - msg ("\n"); - cursor = cursor->next; - nb_elements++; - } - msg (" found nb_elements %d nb_elements %d\n", nb_elements, listP->nb_elements); - AssertFatal(nb_elements == listP->nb_elements, "Bad count of elements %d != %d", nb_elements, listP->nb_elements); - } - }*/ -} diff --git a/targets/TEST/RLC_AM_V9.3.0/Makefile b/targets/TEST/RLC_AM_V9.3.0/Makefile deleted file mode 100644 index 8884d7b667fc6eb96f14fcacd29960afa81966db..0000000000000000000000000000000000000000 --- a/targets/TEST/RLC_AM_V9.3.0/Makefile +++ /dev/null @@ -1,199 +0,0 @@ -include $(OPENAIR_DIR)/common/utils/Makefile.inc - -NUM_CORES=$(shell cat /proc/cpuinfo | grep processor | wc -l) - -TOP_DIR = $(OPENAIR1_DIR) -OPENAIR1_TOP = $(OPENAIR1_DIR) -OPENAIR2_TOP = $(OPENAIR2_DIR) -OPENAIR3_TOP = $(OPENAIR3_DIR) -OPENAIR3 = $(OPENAIR3_DIR) - -CFLAGS += -m32 -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -I/usr/include/X11 - -ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES - -CFLAGS += -DOPENAIR_LTE #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE -CFLAGS += -DMAC_CONTEXT=1 -DPHY_CONTEXT=1 #-DRLC_UM_TEST_TRAFFIC=1 -#CFLAGS += -DLLR8 - -ifndef OPENAIR2 -OPENAIR2=1 -endif - -ifdef TRAFFIC_TM5 -CFLAGS += -DRLC_UM_TEST_TRAFFIC=1 #-DFULL_BUFFER=1 -endif - -# activate OCG and libxml only under linux -ifeq ($(linux),1) -CFLAGS += -I/usr/include/libxml2 -L/usr/local/lib -I/usr/include/atlas -L/usr/X11R6/lib -OCG_FLAG = 1 -cygwin=0 -CFLAGS += -DLINUX -else -cygwin=1 -OCG_FLAG = 0 -endif - - -ifdef XFORMS -CFLAGS += -DXFORMS -endif - -ifdef PRINT_STATS -CFLAGS += -DPRINT_STATS -endif - -ifndef rrc_cellular -rrc_cellular = 0 -rrc_cellular_eNB = 0 -rrc_cellular_UE = 0 -else - ifeq ($(eNB_flag),1) - rrc_cellular_eNB=1 - endif - ifeq ($(UE_flag),1) - rrc_cellular_UE=1 - endif -endif - -ifdef DEBUG_PHY -CFLAGS += -DDEBUG_PHY -endif - -# ln -sf EUTRA-RRC-Definitions-a20.asn EUTRA-RRC-Definitions.asn -# make cleanasn1 -#make all Rel10=1 -export IS_REL10=$(shell if [ -f .lock-rel10 ] ; then echo "1" ; else echo "0" ; fi) -export IS_REL8=$(shell if [ -f .lock-rel8 ] ; then echo "1" ; else echo "0" ; fi) - -ifdef Rel10 -CFLAGS += -DRel10 -ifeq ($(IS_REL10), 0) - $(shell cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/asn1c/ASN1_files/ ; rm EUTRA-RRC-Definitions.asn ; ln -s EUTRA-RRC-Definitions-a20.asn EUTRA-RRC-Definitions.asn ; cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES ; ln -s asn1-86_constants.h asn1_constants.h ; cd $(OPENAIR_TARGETS)/SIMU/USER/ ; rm -f $(ASN1_MSG_OBJS1) ; rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc.generated ; rm -f $(L2_OBJS) ; rm -f *.o ; rm -f oaisim ; touch .lock-rel10 ; rm .lock-rel8 ;) -endif -else # default is rel 8 -ifeq ($(IS_REL8), 0) - $(shell cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/asn1c/ASN1_files/ ; rm EUTRA-RRC-Definitions.asn ; ln -s EUTRA-RRC-Definitions-86.asn EUTRA-RRC-Definitions.asn ; cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES ; ln -s asn1-a20_constants.h asn1_constants.h ; cd $(OPENAIR_TARGETS)/SIMU/USER/ ; rm -f $(ASN1_MSG_OBJS1) ; rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc.generated ; rm -f $(L2_OBJS); rm -f *.o ; rm -f oaisim ; touch .lock-rel8 ; rm .lock-rel10 ; ) -endif -endif - -ifeq ($(NAS), 1) -CFLAGS += -DPDCP_USE_NETLINK -DLINUX -NAS_FLAG=1 -endif - -ifdef TEST_OMG -CFLAGS += -DTEST_OMG -#CFLAGS += -DDEBUG_OMG -endif -# after the execution, a profiling output "gmon.out" will be created, -#then we need to run "gprof ./oaisim > gmon.txt" in the same directory as "gmon.out" -# you could also use the script "grpof2dot.py gmon.txt" for visual diagrams -ifdef GPROF -CFLAGS += -pg -endif - -#require kernel patch for oai driver to enable address autoconfiguration (IPv6 only) -ifdef ADDCONF -CFLAGS+=-DADDRCONF -endif - -ifdef OAI_NW_DRIVER_TYPE_ETHERNET -CFLAGS+=-DOAI_NW_DRIVER_TYPE_ETHERNET -endif - -CFLAGS += $(shell if [ `uname -o` = "Cygwin" ] ; then echo "-DCYGWIN" ;fi) - -CFLAGS += -DENABLE_USE_CPU_EXECUTION_TIME - -ifneq ($(USE_MME), R8) -UPDATE_RELEASE_9=1 -endif - - - -EXTRA_CFLAGS += -DOPENAIR2 -EXTRA_CFLAGS += -DASSERT -EXTRA_CFLAGS += -DNO_RRM -EXTRA_CFLAGS += -DTEST_RLC_AM - -COMMON_DIR = $(OPENAIR2_TOP)/COMMON -L2_INTERFACE_DIR = $(OPENAIR2_TOP)/RRC/L2_INTERFACE -RLC_UM_DIR = $(OPENAIR2_TOP)/LAYER2/RLC/UM_v9.3.0 -RLC_AM_DIR = $(OPENAIR2_TOP)/LAYER2/RLC/AM_v9.3.0 -RLC_TM_DIR = $(OPENAIR2_TOP)/LAYER2/RLC/TM_v9.3.0 -RLC_DIR = $(OPENAIR2_TOP)/LAYER2/RLC -PDCP_DIR = $(OPENAIR2_TOP)/LAYER2/PDCP -MEM_DIR = $(OPENAIR2_TOP)/UTIL/MEM -LIST_DIR = $(OPENAIR2_TOP)/UTIL/LISTS -MATH_DIR = $(OPENAIR2_TOP)/UTIL/MATH -TIMER_DIR = $(OPENAIR2_TOP)/UTIL/TIMER -PHY_INTERFACE_DIR = $(OPENAIR2_TOP)/PHY_INTERFACE -RRC_DIR = $(OPENAIR2_TOP)/RRC/LITE -L2_INTERFACE_DIR = $(OPENAIR2_TOP)/RRC/L2_INTERFACE -MAC_DIR = $(OPENAIR2_TOP)/LAYER2/MAC -LOG_DIR=$(OPENAIR2_TOP)/UTIL/LOG -OCG_DIR=$(OPENAIR2_TOP)/UTIL/OCG -OPT_DIR=$(OPENAIR2_TOP)/UTIL/OPT - - -SOURCES_L2 = $(LIST_DIR)/list.c -SOURCES_L2 += $(LIST_DIR)/list2.c - -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_init.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_timer_poll_retransmit.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_timer_reordering.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_timer_status_prohibit.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_segment.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_segments_holes.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_in_sdu.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_receiver.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_retransmit.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_windows.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_rx_list.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_reassembly.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_status_report.c -SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_test.c - -SOURCES_L2 += $(MEM_DIR)/mem_block.c - -LOG_OBJS = $(LOG_DIR)/log.o -LOG_OBJS += $(LOG_DIR)/vcd_signal_dumper.o -OPT_OBJS = $(OPT_DIR)/probe.o - -L2_OBJS=$(addsuffix .o,$(basename $(SOURCES_L2))) $(PHY_INTERFACE_OBJS) $(MAC_OBJS) $(L2_INTERFACE_OBJS) $(RRC_OBJS) $(LOG_OBJS) $(OPT_OBJS) - - -L2_incl = -I$(OPENAIR2_TOP) -I$(COMMON_DIR) -I$(RLC_DIR) -I$(RLC_AM_DIR) -I$(RLC_UM_DIR) -I$(RLC_TM_DIR) -I$(PDCP_DIR) -I$(MEM_DIR) -I$(LIST_DIR) -I$(LOG_DIR) -I$(MATH_DIR) -I$(TIMER_DIR) -I$(OPENAIR3)/MESH -I$(OPENAIR2_TOP)/RRC/LITE -I$(OPENAIR2_TOP)/RRC/LITE/MESSAGES -I$(OPENAIR3)/MESH/RRM -I$(OPT_DIR) - - - - - -ASN1_MSG_OBJS2 := $(foreach file, $(ASN1_MSG_OBJS), $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/$(file)) - -OBJ = $(PHY_OBJS) $(SIMULATION_OBJS) $(SCHED_OBJS) $(STATS_OBJS) $(ASN1_MSG_OBJS2) - -all: testam - - -$(OBJ) : %.o : %.c - $(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) -DPHY_CONTEXT=1 -I$(TOP_DIR) $(L2_incl) -I$(ASN1_MSG_INC) -o $@ $< - -$(L2_OBJS) : %.o : %.c - $(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) -DMAC_CONTEXT=1 -DPHY_CONTEXT=1 -I$(TOP_DIR) $(L2_incl) -I$(ASN1_MSG_INC) -o $@ $< - -testam : $(OBJ) $(L2_OBJS) oaisim.c - echo CYGWIN variable is $(cygwin) - $(CC) oaisim.c -I$(TOP_DIR) $(L2_incl) -I$(ASN1_MSG_INC) -o testam $(CFLAGS) $(EXTRA_CFLAGS) $(OBJ) $(L2_OBJS) -lm -lrt - - -clean: - rm -f testam - rm -f $(OBJ) - rm -f $(L2_OBJS) - rm -f *.o - rm -f *.exe* - diff --git a/targets/TEST/RLC_AM_V9.3.0/oaisim.c b/targets/TEST/RLC_AM_V9.3.0/oaisim.c deleted file mode 100644 index fc2082f1df64549e8f4a8d8702b43880865a05ba..0000000000000000000000000000000000000000 --- a/targets/TEST/RLC_AM_V9.3.0/oaisim.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include <string.h> -#include <math.h> -#include <unistd.h> -#include "SIMULATION/TOOLS/defs.h" -#include "SIMULATION/RF/defs.h" -#include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/vars.h" -#include "MAC_INTERFACE/vars.h" - -#include "rlc_am.h" -#include "rlc_am_test.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/vars.h" -#include "UTIL/LOG/log_if.h" -#include "UTIL/LOG/log_extern.h" -#include "RRC/LTE/vars.h" -#include "PHY_INTERFACE/vars.h" -#include "UTIL/OCG/OCG.h" - - - -int main(int argc, char **argv) -{ - - //initialize the log generator - logInit(); - mac_xface = malloc(sizeof(MAC_xface)); - rlc_am_v9_3_0_test(); - return(0); -} - - diff --git a/targets/TEST/RLC_UM_V9.3.0/Makefile b/targets/TEST/RLC_UM_V9.3.0/Makefile deleted file mode 100644 index 919def5f1e29680119a8fee96545d61802a8d69b..0000000000000000000000000000000000000000 --- a/targets/TEST/RLC_UM_V9.3.0/Makefile +++ /dev/null @@ -1,188 +0,0 @@ -include $(OPENAIR_DIR)/common/utils/Makefile.inc - -NUM_CORES=$(shell cat /proc/cpuinfo | grep processor | wc -l) - -TOP_DIR = $(OPENAIR1_DIR) -OPENAIR1_TOP = $(OPENAIR1_DIR) -OPENAIR2_TOP = $(OPENAIR2_DIR) -OPENAIR3_TOP = $(OPENAIR3_DIR) -OPENAIR3 = $(OPENAIR3_DIR) - -CFLAGS += -m32 -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -I/usr/include/X11 - -ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES - -CFLAGS += -DOPENAIR_LTE #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE -CFLAGS += -DMAC_CONTEXT=1 -DPHY_CONTEXT=1 #-DRLC_UM_TEST_TRAFFIC=1 -#CFLAGS += -DLLR8 - -ifndef OPENAIR2 -OPENAIR2=1 -endif - -ifdef TRAFFIC_TM5 -CFLAGS += -DRLC_UM_TEST_TRAFFIC=1 #-DFULL_BUFFER=1 -endif - -# activate OCG and libxml only under linux -ifeq ($(linux),1) -CFLAGS += -I/usr/include/libxml2 -L/usr/local/lib -I/usr/include/atlas -L/usr/X11R6/lib -OCG_FLAG = 1 -CFLAGS += -DLINUX -else -OCG_FLAG = 0 -endif - -ifdef XFORMS -CFLAGS += -DXFORMS -endif - -ifdef PRINT_STATS -CFLAGS += -DPRINT_STATS -endif - -ifndef rrc_cellular -rrc_cellular = 0 -rrc_cellular_eNB = 0 -rrc_cellular_UE = 0 -else - ifeq ($(eNB_flag),1) - rrc_cellular_eNB=1 - endif - ifeq ($(UE_flag),1) - rrc_cellular_UE=1 - endif -endif - -ifdef DEBUG_PHY -CFLAGS += -DDEBUG_PHY -endif - -# ln -sf EUTRA-RRC-Definitions-a20.asn EUTRA-RRC-Definitions.asn -# make cleanasn1 -#make all Rel10=1 -export IS_REL10=$(shell if [ -f .lock-rel10 ] ; then echo "1" ; else echo "0" ; fi) -export IS_REL8=$(shell if [ -f .lock-rel8 ] ; then echo "1" ; else echo "0" ; fi) - -ifdef Rel10 -CFLAGS += -DRel10 -ifeq ($(IS_REL10), 0) - $(shell cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/asn1c/ASN1_files/ ; rm EUTRA-RRC-Definitions.asn ; ln -s EUTRA-RRC-Definitions-a20.asn EUTRA-RRC-Definitions.asn ; cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES ; ln -s asn1-86_constants.h asn1_constants.h ; cd $(OPENAIR_TARGETS)/SIMU/USER/ ; rm -f $(ASN1_MSG_OBJS1) ; rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc.generated ; rm -f $(L2_OBJS) ; rm -f *.o ; rm -f oaisim ; touch .lock-rel10 ; rm .lock-rel8 ;) -endif -else # default is rel 8 -ifeq ($(IS_REL8), 0) - $(shell cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/asn1c/ASN1_files/ ; rm EUTRA-RRC-Definitions.asn ; ln -s EUTRA-RRC-Definitions-86.asn EUTRA-RRC-Definitions.asn ; cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES ; ln -s asn1-a20_constants.h asn1_constants.h ; cd $(OPENAIR_TARGETS)/SIMU/USER/ ; rm -f $(ASN1_MSG_OBJS1) ; rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc.generated ; rm -f $(L2_OBJS); rm -f *.o ; rm -f oaisim ; touch .lock-rel8 ; rm .lock-rel10 ; ) -endif -endif - -ifeq ($(NAS), 1) -CFLAGS += -DPDCP_USE_NETLINK -DLINUX -NAS_FLAG=1 -endif - -ifdef TEST_OMG -CFLAGS += -DTEST_OMG -#CFLAGS += -DDEBUG_OMG -endif -# after the execution, a profiling output "gmon.out" will be created, -#then we need to run "gprof ./oaisim > gmon.txt" in the same directory as "gmon.out" -# you could also use the script "grpof2dot.py gmon.txt" for visual diagrams -ifdef GPROF -CFLAGS += -pg -endif - -#require kernel patch for oai driver to enable address autoconfiguration (IPv6 only) -ifdef ADDCONF -CFLAGS+=-DADDRCONF -endif - -ifdef OAI_NW_DRIVER_TYPE_ETHERNET -CFLAGS+=-DOAI_NW_DRIVER_TYPE_ETHERNET -endif - -CFLAGS += -DENABLE_USE_CPU_EXECUTION_TIME - -ifneq ($(USE_MME), R8) -UPDATE_RELEASE_9=1 -endif - - - -EXTRA_CFLAGS += -DOPENAIR2 -EXTRA_CFLAGS += -DASSERT -EXTRA_CFLAGS += -DNO_RRM -EXTRA_CFLAGS += -DTEST_RLC_UM - -COMMON_DIR = $(OPENAIR2_TOP)/COMMON -L2_INTERFACE_DIR = $(OPENAIR2_TOP)/RRC/L2_INTERFACE -RLC_UM_DIR = $(OPENAIR2_TOP)/LAYER2/RLC/UM_v9.3.0 -RLC_AM_DIR = $(OPENAIR2_TOP)/LAYER2/RLC/AM_v9.3.0 -RLC_TM_DIR = $(OPENAIR2_TOP)/LAYER2/RLC/TM_v9.3.0 -RLC_DIR = $(OPENAIR2_TOP)/LAYER2/RLC -PDCP_DIR = $(OPENAIR2_TOP)/LAYER2/PDCP -MEM_DIR = $(OPENAIR2_TOP)/UTIL/MEM -LIST_DIR = $(OPENAIR2_TOP)/UTIL/LISTS -MATH_DIR = $(OPENAIR2_TOP)/UTIL/MATH -TIMER_DIR = $(OPENAIR2_TOP)/UTIL/TIMER -PHY_INTERFACE_DIR = $(OPENAIR2_TOP)/PHY_INTERFACE -RRC_DIR = $(OPENAIR2_TOP)/RRC/LITE -L2_INTERFACE_DIR = $(OPENAIR2_TOP)/RRC/L2_INTERFACE -MAC_DIR = $(OPENAIR2_TOP)/LAYER2/MAC -LOG_DIR=$(OPENAIR2_TOP)/UTIL/LOG -OCG_DIR=$(OPENAIR2_TOP)/UTIL/OCG -OPT_DIR=$(OPENAIR2_TOP)/UTIL/OPT - - -SOURCES_L2 = $(LIST_DIR)/list.c -SOURCES_L2 += $(LIST_DIR)/list2.c - -SOURCES_L2 += $(RLC_UM_DIR)/rlc_um.c -SOURCES_L2 += $(RLC_UM_DIR)/rlc_um_control_primitives.c -SOURCES_L2 += $(RLC_UM_DIR)/rlc_um_dar.c -SOURCES_L2 += $(RLC_UM_DIR)/rlc_um_fsm.c -SOURCES_L2 += $(RLC_UM_DIR)/rlc_um_reassembly.c -SOURCES_L2 += $(RLC_UM_DIR)/rlc_um_receiver.c -SOURCES_L2 += $(RLC_UM_DIR)/rlc_um_segment.c -SOURCES_L2 += $(RLC_UM_DIR)/rlc_um_test.c - - -SOURCES_L2 += $(MEM_DIR)/mem_block.c - -LOG_OBJS = $(LOG_DIR)/log.o -LOG_OBJS += $(LOG_DIR)/vcd_signal_dumper.o -OPT_OBJS = $(OPT_DIR)/probe.o - -L2_OBJS=$(addsuffix .o,$(basename $(SOURCES_L2))) $(PHY_INTERFACE_OBJS) $(MAC_OBJS) $(L2_INTERFACE_OBJS) $(RRC_OBJS) $(LOG_OBJS) $(OPT_OBJS) - - -L2_incl = -I$(OPENAIR2_TOP) -I$(COMMON_DIR) -I$(RLC_DIR) -I$(RLC_AM_DIR) -I$(RLC_UM_DIR) -I$(RLC_TM_DIR) -I$(PDCP_DIR) -I$(MEM_DIR) -I$(LIST_DIR) -I$(LOG_DIR) -I$(MATH_DIR) -I$(TIMER_DIR) -I$(OPENAIR3)/MESH -I$(OPENAIR2_TOP)/RRC/LITE -I$(OPENAIR2_TOP)/RRC/LITE/MESSAGES -I$(OPENAIR3)/MESH/RRM -I$(OPT_DIR) - - - - - - -ASN1_MSG_OBJS2 := $(foreach file, $(ASN1_MSG_OBJS), $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/$(file)) - -OBJ = $(PHY_OBJS) $(SIMULATION_OBJS) $(SCHED_OBJS) $(STATS_OBJS) $(ASN1_MSG_OBJS2) - -all: testum - - -$(OBJ) : %.o : %.c - $(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) -DPHY_CONTEXT=1 -I$(TOP_DIR) $(L2_incl) -I$(ASN1_MSG_INC) -o $@ $< - -$(L2_OBJS) : %.o : %.c - $(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) -DMAC_CONTEXT=1 -DTEST_RLC_UM=1 -DPHY_CONTEXT=1 -I$(TOP_DIR) $(L2_incl) -I$(ASN1_MSG_INC) -o $@ $< - -testum : $(OBJ) $(L2_OBJS) oaisim.c - $(CC) oaisim.c -I$(TOP_DIR) $(L2_incl) -I$(ASN1_MSG_INC) -o testum $(CFLAGS) $(EXTRA_CFLAGS) $(OBJ) $(L2_OBJS) -lm -lrt - - -clean: - rm -f testum - rm -f $(OBJ) - rm -f $(L2_OBJS) - rm -f *.o - rm -f *.exe* - diff --git a/targets/TEST/RLC_UM_V9.3.0/oaisim.c b/targets/TEST/RLC_UM_V9.3.0/oaisim.c deleted file mode 100644 index c520749de333b4fda4ac80b17c50402f110d27b0..0000000000000000000000000000000000000000 --- a/targets/TEST/RLC_UM_V9.3.0/oaisim.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include <string.h> -#include <math.h> -#include <unistd.h> -#include "SIMULATION/TOOLS/defs.h" -#include "SIMULATION/RF/defs.h" -#include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/vars.h" -#include "MAC_INTERFACE/vars.h" - -#include "rlc.h" -#include "rlc_um.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/vars.h" -#include "UTIL/LOG/log_if.h" -#include "UTIL/LOG/log_extern.h" -#include "RRC/LTE/vars.h" -#include "PHY_INTERFACE/vars.h" -#include "UTIL/OCG/OCG.h" - - - -int main(int argc, char **argv) -{ - logInit(); - mac_xface = malloc(sizeof(MAC_xface)); - rlc_um_v9_3_0_test(); - return(0); -} - -