diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index 2ed2917bba631e958fe5f76c24520ef3ee928e18..463507bd4eff8b07d9671644290cc9e05231bfad 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -36,6 +36,7 @@ # include "intertask_interface.h" #endif #include "assertions.h" +#include "msc.h" #include "hashtable.h" #include "rlc_am.h" #include "rlc_am_segment.h" @@ -47,7 +48,6 @@ #include "UTIL/LOG/log.h" #include "UL-AM-RLC.h" #include "DL-AM-RLC.h" -#include "msc.h" //#define TRACE_RLC_AM_DATA_REQUEST //#define TRACE_RLC_AM_TX_STATUS //#define TRACE_RLC_AM_TX @@ -1107,7 +1107,7 @@ rlc_am_data_req ( int octet_index, index; #endif - pthread_mutex_lock(&l_rlc_p->lock_input_sdus); + 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) && @@ -1254,5 +1254,5 @@ rlc_am_data_req ( #endif } - pthread_mutex_unlock(&l_rlc_p->lock_input_sdus); + 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 index c3a10fd2cefd109ed68117de59d5c83abf96024b..aa7fab38c378fe9f99f870d113c41c51bff58158 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h @@ -96,6 +96,32 @@ (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) {\ + MSC_LOG_EVENT((cTXT->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,\ + PROTOCOL_RLC_AM_MSC_FMT" Warning try lock %s busy",\ + PROTOCOL_RLC_AM_MSC_ARGS(cTXT,rLC),\ + #mUTEX);\ + pthread_mutex_lock(mUTEX);\ + } else {\ + MSC_LOG_EVENT((cTXT->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,\ + PROTOCOL_RLC_AM_MSC_FMT" Error try lock %s %d",\ + PROTOCOL_RLC_AM_MSC_ARGS(cTXT,rLC),\ + #mUTEX, pmtl_rc);\ + }\ + }\ + } 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. 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 index 69f53aec6143179c24c6cd3e345d0b8d9553a32a..3549f7b5bd717faa17101b9c5e93a3a3769aa968 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c @@ -180,7 +180,7 @@ rlc_am_send_sdu ( # endif # endif #if !defined(ENABLE_ITTI) - pthread_mutex_unlock(&rlc_pP->lock_input_sdus); + RLC_AM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); #endif MSC_LOG_TX_MESSAGE( (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, @@ -200,7 +200,7 @@ rlc_am_send_sdu ( rlc_pP->output_sdu_size_to_write, rlc_pP->output_sdu_in_construction); #if !defined(ENABLE_ITTI) - pthread_mutex_lock(&rlc_pP->lock_input_sdus); + RLC_AM_MUTEX_LOCK(&rlc_pP->lock_input_sdus, ctxt_pP, rlc_pP); #endif #endif rlc_pP->output_sdu_in_construction = NULL; 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 index 5d79ac68355fd4e3a39a10f3a64cedb9ca390693..ef5cced0b4fbeb1bd0453b170833a5f705cbefaa 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c @@ -32,6 +32,7 @@ #include "platform_types.h" //----------------------------------------------------------------------------- #include "assertions.h" +#include "msc.h" #include "rlc.h" #include "rlc_am.h" #include "list.h" @@ -271,7 +272,7 @@ rlc_am_receive_routing ( mem_block_t *tb_p = NULL; uint8_t *first_byte_p = NULL; sdu_size_t tb_size_in_bytes; - pthread_mutex_lock(&rlc_pP->lock_input_sdus); + 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; @@ -298,7 +299,7 @@ rlc_am_receive_routing ( rlc_pP->vr_mr); } } // end while - pthread_mutex_unlock(&rlc_pP->lock_input_sdus); + RLC_AM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); } //----------------------------------------------------------------------------- void 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 index 81f027fce676657a3319108b4d2f8d35e7970a09..4efc4f2742caecde6cd65730e4d6afd3679ff940 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c @@ -36,6 +36,7 @@ //#include "rtos_header.h" #include "platform_types.h" //----------------------------------------------------------------------------- +#include "msc.h" #include "list.h" #include "rlc_am.h" #include "LAYER2/MAC/extern.h" @@ -175,7 +176,7 @@ void rlc_am_segment_10 ( pdu_mem_p = NULL; - pthread_mutex_lock(&rlc_pP->lock_input_sdus); + 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", @@ -210,7 +211,7 @@ void rlc_am_segment_10 ( if (!(pdu_mem_p = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req)))) { LOG_C(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); - pthread_mutex_unlock(&rlc_pP->lock_input_sdus); + RLC_AM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); return; } @@ -543,5 +544,5 @@ void rlc_am_segment_10 ( } - pthread_mutex_unlock(&rlc_pP->lock_input_sdus); + RLC_AM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c index fc6542b22c9f4d127ba060cd2e6326a4b5f22971..beea383483da463cc6125c8c25e727ddcd4c5e2b 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c @@ -37,13 +37,13 @@ # include "intertask_interface.h" #endif #include "assertions.h" +#include "msc.h" #include "rlc_um.h" #include "list.h" #include "rlc_primitives.h" #include "mac_primitives.h" #include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" -#include "msc.h" #include "rlc_um_very_simple_test.h" @@ -779,8 +779,8 @@ rlc_um_data_req (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, mem_block_t LOG_T(RLC, "%s", message_string); #endif # endif - pthread_mutex_lock(&rlc_p->lock_input_sdus); + 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); - pthread_mutex_unlock(&rlc_p->lock_input_sdus); + RLC_UM_MUTEX_UNLOCK(&rlc_p->lock_input_sdus); } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h index 7bfc57f7f9df81e27d0c7abe88550ef475c5dba4..9d49b53c7d92887ee247d0628d28ce428469f028 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h @@ -56,6 +56,7 @@ # define public_rlc_um(x) extern x # endif # endif +# include <errno.h> # include "platform_types.h" # include "rlc_def.h" # include "rlc_def_lte.h" @@ -86,6 +87,31 @@ (rLC_Pp->is_data_plane) ? "DRB UM" : "SRB UM",\ rLC_Pp->rb_id +#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) {\ + MSC_LOG_EVENT((cTXT->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,\ + PROTOCOL_RLC_UM_MSC_FMT" Warning try lock %s busy",\ + PROTOCOL_RLC_UM_MSC_ARGS(cTXT,rLC),\ + #mUTEX);\ + pthread_mutex_lock(mUTEX);\ + } else {\ + MSC_LOG_EVENT((cTXT->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,\ + PROTOCOL_RLC_UM_MSC_FMT" Error try lock %s %d",\ + PROTOCOL_RLC_UM_MSC_ARGS(cTXT,rLC),\ + #mUTEX, pmtl_rc);\ + }\ + }\ + } 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, 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 index 1810c68fd780b844153f4401bb8ae6e747ae9b65..56e31305923f2195cf07bb32732c63edec403c21 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c @@ -31,6 +31,7 @@ #include "platform_types.h" #include "assertions.h" //----------------------------------------------------------------------------- +#include "msc.h" #include "rlc.h" #include "rlc_um.h" #include "rlc_primitives.h" @@ -744,7 +745,7 @@ void rlc_um_check_timer_dar_time_out( rlc_um_stop_and_reset_timer_reordering(ctxt_pP, rlc_pP); } - pthread_mutex_unlock(&rlc_pP->lock_dar_buffer); + RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_dar_buffer); } } } @@ -983,7 +984,7 @@ rlc_um_receive_process_dar ( free_mem_block(pdu_mem_pP); } - pthread_mutex_lock(&rlc_pP->lock_dar_buffer); + 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); @@ -1007,7 +1008,7 @@ rlc_um_receive_process_dar ( rlc_pP->stat_rx_data_bytes_out_of_window += tb_sizeP; free_mem_block(pdu_mem_pP); pdu_mem_pP = NULL; - pthread_mutex_unlock(&rlc_pP->lock_dar_buffer); + 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; } @@ -1026,7 +1027,7 @@ rlc_um_receive_process_dar ( rlc_pP->stat_rx_data_bytes_duplicate += tb_sizeP; free_mem_block(pdu_mem_pP); pdu_mem_pP = NULL; - pthread_mutex_unlock(&rlc_pP->lock_dar_buffer); + 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; } @@ -1159,6 +1160,6 @@ rlc_um_receive_process_dar ( } } - pthread_mutex_unlock(&rlc_pP->lock_dar_buffer); + 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_segment.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c index c5deba88386879778f6b7d3feecd1a02364bb88f..12400c6e944dcd6c27a407177efdbabbf431cfa8 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c @@ -36,6 +36,7 @@ #include <assert.h> #endif #include "assertions.h" +#include "msc.h" #include "list.h" #include "rlc_um.h" #include "rlc_primitives.h" @@ -45,7 +46,7 @@ //#define TRACE_RLC_UM_SEGMENT 1 //----------------------------------------------------------------------------- void -rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) +rlc_um_segment_10 (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP) { //----------------------------------------------------------------------------- list_t pdus; @@ -89,7 +90,7 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) pdu_mem_p = NULL; // not fine locking - pthread_mutex_lock(&rlc_pP->lock_input_sdus); + 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)) { @@ -129,7 +130,7 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) 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 - pthread_mutex_unlock(&rlc_pP->lock_input_sdus); + RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); return; } @@ -432,11 +433,11 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) nb_bytes_to_transmit = 0; // 1 PDU only } - pthread_mutex_unlock(&rlc_pP->lock_input_sdus); + RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); } //----------------------------------------------------------------------------- void -rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) +rlc_um_segment_5 (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP) { //----------------------------------------------------------------------------- list_t pdus; @@ -479,7 +480,7 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) list_init (&pdus, NULL); // param string identifying the list is NULL pdu_mem_p = NULL; - pthread_mutex_lock(&rlc_pP->lock_input_sdus); + 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 defined(TRACE_RLC_UM_SEGMENT) @@ -518,7 +519,7 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) 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 - pthread_mutex_unlock(&rlc_pP->lock_input_sdus); + RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); return; } @@ -817,6 +818,6 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP) nb_bytes_to_transmit = 0; // 1 PDU only } - pthread_mutex_unlock(&rlc_pP->lock_input_sdus); + RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus); }