From 675fd0af4e3d0c2cb9a76e91d9567e3cbf80c8ca Mon Sep 17 00:00:00 2001 From: Wu Jing <wu.jing@cn.fujitsu.com> Date: Thu, 1 Feb 2018 14:46:34 +0900 Subject: [PATCH] patch develop-get-freememblock.patch into closed_item --- .../LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c | 1 + openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c | 4 ++++ .../LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c | 15 ++++++++++++--- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c | 4 ++-- openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c | 1 + openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c | 7 +++---- openair2/UTIL/MEM/mem_block.c | 6 +++--- openair2/UTIL/MEM/mem_block.h | 2 +- openair2/UTIL/TIMER/umts_timer.c | 1 + targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c | 2 +- 10 files changed, 29 insertions(+), 14 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c index abec97ddfd..0ef6893d08 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c @@ -45,6 +45,7 @@ configure_pdcp_req (struct pdcp_entity *pdcpP, void *rlcP, uint8_t rlc_sap_typeP mem_block *mb; mb = get_free_mem_block (sizeof (struct cpdcp_primitive), __func__); + if(mb==NULL) return; ((struct cpdcp_primitive *) mb->data)->type = CPDCP_CONFIG_REQ; ((struct cpdcp_primitive *) mb->data)->primitive.config_req.rlc_sap = rlcP; ((struct cpdcp_primitive *) mb->data)->primitive.config_req.rlc_type_sap = rlc_sap_typeP; 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 index 9e1db8a95b..add950786c 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c @@ -265,6 +265,7 @@ mem_block_t* rlc_am_retransmit_get_copy ( /* 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)]); @@ -339,6 +340,7 @@ mem_block_t* rlc_am_retransmit_get_am_segment( *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; @@ -551,6 +553,7 @@ mem_block_t* rlc_am_retransmit_get_am_segment( 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; @@ -718,6 +721,7 @@ mem_block_t* rlc_am_retransmit_get_subsegment( if (mb_original_p != NULL) { mem_block_t* mb_sub_segment_p = get_free_mem_block(*sizeP + sizeof(struct mac_tb_req), __func__); + if(mb_sub_segment_p == NULL) return NULL; rlc_am_pdu_sn_10_t* pdu_original_p = (rlc_am_pdu_sn_10_t*) (&mb_original_p->data[sizeof(struct mac_tb_req)]); rlc_am_pdu_sn_10_t* pdu_sub_segment_p = (rlc_am_pdu_sn_10_t*) (&mb_sub_segment_p->data[sizeof(struct mac_tb_req)]); rlc_am_pdu_info_t pdu_info; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c index 092c7c65f1..cb9a6a3621 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c @@ -212,6 +212,9 @@ rlc_am_get_control_pdu_infos( 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; } @@ -225,7 +228,9 @@ rlc_am_get_control_pdu_infos( } 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; @@ -388,13 +393,15 @@ rlc_am_receive_process_control_pdu( } else { - LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT" WARNING CONTROL PDU ACK SN %d OUT OF WINDOW vtA=%d vtS=%d\n", + 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_W(RLC, PROTOCOL_RLC_AM_CTXT_FMT" ERROR IN DECODING CONTROL PDU\n", + 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; } @@ -807,6 +814,7 @@ rlc_am_send_status_pdu( pdu_size); #endif 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)]); @@ -1151,6 +1159,7 @@ end_push_nack: pdu_size); #endif 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)]); 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 index ff969c0b6e..d9eb6de7cc 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c @@ -534,7 +534,7 @@ void rlc_am_v9_3_0_test_send_sdu(rlc_am_entity_t *am_txP, int 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); +// exit(-1); } } //----------------------------------------------------------------------------- @@ -577,7 +577,7 @@ void rlc_am_v9_3_0_test_mac_rlc_loop (struct mac_data_ind *data_indP, struct ma data_indP->no_tb += 1; } else { printf("Out of memory error\n"); - exit(-1); +// exit(-1); } } else { printf("[RLC-LOOP] DROPPING 1 TB\n"); 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 index 15dc90f175..972d40bb3f 100644 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c @@ -83,6 +83,7 @@ void rlc_tm_init ( 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 *)); } 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 index 2c1fa9333f..4d238ea841 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c @@ -317,7 +317,7 @@ void rlc_um_v9_3_0_test_send_sdu(rlc_um_entity_t *um_txP, int 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); +// exit(-1); } } @@ -406,9 +406,8 @@ void rlc_um_v9_3_0_test_mac_rlc_loop (struct mac_data_ind* data_indP, struct ma if (*drop_countP == 0) { tb_dst = get_free_mem_block(sizeof (mac_rlc_max_rx_header_size_t) + tb_size, __func__); - memset(tb_dst->data, 0, sizeof (mac_rlc_max_rx_header_size_t) + tb_size); - 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; @@ -427,7 +426,7 @@ void rlc_um_v9_3_0_test_mac_rlc_loop (struct mac_data_ind* data_indP, struct ma check_free_mem_block(tb_dst, __func__); } else { printf("Out of memory error\n"); - exit(-1); +// exit(-1); } } else { printf("[RLC-LOOP] DROPPING 1 TB\n"); diff --git a/openair2/UTIL/MEM/mem_block.c b/openair2/UTIL/MEM/mem_block.c index 9c3a50467a..cfc8081a4b 100644 --- a/openair2/UTIL/MEM/mem_block.c +++ b/openair2/UTIL/MEM/mem_block.c @@ -275,9 +275,9 @@ get_free_mem_block (uint32_t sizeP, const char* caller) } while (pool_selected++ < 12); LOG_E(PHY, "[MEM_MNGT][ERROR][FATAL] failed allocating MEM_BLOCK size %d byes (pool_selected=%d size=%d)\n", sizeP, pool_selected, size); - display_mem_load(); - AssertFatal(1==0,"get_free_mem_block failed"); - +// display_mem_load(); +// AssertFatal(1==0,"get_free_mem_block failed"); + LOG_E(MAC,"[MEM_MNGT][ERROR][FATAL] get_free_mem_block failed!!!\n"); #ifdef MEMBLOCK_BIG_LOCK if (pthread_mutex_unlock(&mtex)) abort(); #endif diff --git a/openair2/UTIL/MEM/mem_block.h b/openair2/UTIL/MEM/mem_block.h index e967380269..30554c518a 100644 --- a/openair2/UTIL/MEM/mem_block.h +++ b/openair2/UTIL/MEM/mem_block.h @@ -91,7 +91,7 @@ private_mem_block(void check_free_mem_block (mem_block_t * leP);) # define MEM_MNGT_MB5_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*32 // 2048 -# define MEM_MNGT_MB5_NB_BLOCKS 1024 * MEM_SCALE // LG WAS 1024 +# define MEM_MNGT_MB5_NB_BLOCKS 1024 * MEM_SCALE * 50 // LG WAS 1024 # define MEM_MNGT_POOL_ID5 5 # define MEM_MNGT_MB6_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*64 diff --git a/openair2/UTIL/TIMER/umts_timer.c b/openair2/UTIL/TIMER/umts_timer.c index 9bbb6c2df9..1691fac363 100644 --- a/openair2/UTIL/TIMER/umts_timer.c +++ b/openair2/UTIL/TIMER/umts_timer.c @@ -94,6 +94,7 @@ umts_add_timer_list_up (list2_t * atimer_listP, void (*procP) (void *, void *), uint8_t inserted = 0; mb = get_free_mem_block (sizeof (struct timer_unit), __func__); + if(mb==NULL) return NULL; ((struct timer_unit *) (mb->data))->proc = procP; ((struct timer_unit *) (mb->data))->protocol = protocolP; ((struct timer_unit *) (mb->data))->timer_id = timer_idP; diff --git a/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c b/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c index 1cadea3715..3e1dd2ea8e 100644 --- a/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c +++ b/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c @@ -148,7 +148,7 @@ void pdcp_rlc_test_mac_rlc_loop (struct mac_data_ind *data_indP, struct mac_dat data_indP->no_tb += 1; } else { printf("Out of memory error\n"); - exit(-1); +// exit(-1); } } else { printf("[RLC-LOOP] DROPPING 1 TB\n"); -- GitLab