Commit f4dd623f authored by francescomani's avatar francescomani

more leaks fixed

parent 9c6f94e1
......@@ -364,6 +364,7 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time[i]);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted[i]);
}
free_and_zero(gNB->nr_srs_info[id]->sc_list);
free_and_zero(gNB->nr_srs_info[id]->srs_generated_signal);
free_and_zero(gNB->nr_srs_info[id]->noise_power);
free_and_zero(gNB->nr_srs_info[id]->srs_received_signal);
......@@ -572,9 +573,10 @@ void init_DLSCH_struct(PHY_VARS_gNB *gNB, processingData_L1tx_t *msg) {
uint16_t grid_size = cfg->carrier_config.dl_grid_size[fp->numerology_index].value;
msg->num_pdsch_slot = 0;
int num_cw = NR_MAX_NB_LAYERS > 4? 2:1;
for (int i=0; i<gNB->number_of_nr_dlsch_max; i++) {
LOG_I(PHY,"Allocating Transport Channel Buffers for DLSCH %d/%d\n",i,gNB->number_of_nr_dlsch_max);
for (int j=0; j<2; j++) {
for (int j=0; j<num_cw; j++) {
msg->dlsch[i][j] = new_gNB_dlsch(fp,1,16,NSOFT,0,grid_size);
AssertFatal(msg->dlsch[i][j]!=NULL,"Can't initialize dlsch %d \n", i);
}
......@@ -586,8 +588,9 @@ void reset_DLSCH_struct(const PHY_VARS_gNB *gNB, processingData_L1tx_t *msg)
const NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
const nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
const uint16_t grid_size = cfg->carrier_config.dl_grid_size[fp->numerology_index].value;
int num_cw = NR_MAX_NB_LAYERS > 4? 2:1;
for (int i=0; i<gNB->number_of_nr_dlsch_max; i++)
for (int j=0; j<2; j++)
for (int j=0; j<num_cw; j++)
free_gNB_dlsch(&msg->dlsch[i][j], grid_size, fp);
}
......
......@@ -155,23 +155,6 @@ void phy_term_nr_ue__PDSCH(NR_UE_PDSCH* pdsch, const NR_DL_FRAME_PARMS *const fp
free_and_zero(pdsch->dl_ch_ptrs_estimates_ext);
}
void phy_init_nr_ue_PUSCH(NR_UE_PUSCH *const pusch,
const NR_DL_FRAME_PARMS *const fp) {
AssertFatal( pusch, "pusch==0" );
int max_pusch_length = fp->N_RB_UL*NR_SYMBOLS_PER_SLOT*NR_NB_SC_PER_RB*8*fp->nb_antennas_tx;
pusch->txdataF_layers = (int32_t **)malloc16_clear(fp->nb_antennas_tx*sizeof(int32_t *));
for (int i=0; i<fp->nb_antennas_tx; i++) {
pusch->txdataF_layers[i] = (int32_t *)malloc16_clear(max_pusch_length*sizeof(int32_t));
}
}
void phy_term_nr_ue_PUSCH(NR_UE_PUSCH *pusch,
const NR_DL_FRAME_PARMS* fp)
{
for (int i = 0; i < fp->nb_antennas_tx; i++)
free_and_zero(pusch->txdataF_layers[i]);
}
int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
{
// create shortcuts
......@@ -215,15 +198,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
// init NR modulation lookup tables
nr_generate_modulation_table();
/////////////////////////PUSCH init/////////////////////////
///////////
for (th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
for (gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) {
ue->pusch_vars[th_id][gNB_id] = (NR_UE_PUSCH *)malloc16(sizeof(NR_UE_PUSCH));
phy_init_nr_ue_PUSCH( ue->pusch_vars[th_id][gNB_id], fp );
}
}
/////////////////////////PUCCH init/////////////////////////
///////////
for (th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
......@@ -514,8 +488,6 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
for (int gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) {
phy_term_nr_ue_PUSCH(ue->pusch_vars[th_id][gNB_id],fp);
free_and_zero(ue->pusch_vars[th_id][gNB_id]);
free_and_zero(ue->pucch_vars[th_id][gNB_id]);
}
}
......@@ -640,6 +612,7 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
free_and_zero(ue->nr_srs_info->srs_estimated_channel_time[i]);
free_and_zero(ue->nr_srs_info->srs_estimated_channel_time_shifted[i]);
}
free_and_zero(ue->nr_srs_info->sc_list);
free_and_zero(ue->nr_srs_info->srs_generated_signal);
free_and_zero(ue->nr_srs_info->noise_power);
free_and_zero(ue->nr_srs_info->srs_received_signal);
......
......@@ -73,6 +73,7 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr,
free(harq->c[r]);
harq->c[r] = NULL;
}
free(harq->c);
free(harq->pdu);
for (int aa = 0; aa < 64; aa++)
......@@ -82,6 +83,7 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr,
int nb_codewords = NR_MAX_NB_LAYERS > 4 ? 2 : 1;
for (int q=0; q<nb_codewords; q++)
free(dlsch->mod_symbs[q]);
free(dlsch->mod_symbs);
for (int layer = 0; layer < max_layers; layer++) {
free(dlsch->txdataF[layer]);
......@@ -89,6 +91,8 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr,
free(dlsch->ue_spec_bf_weights[layer][aa]);
free(dlsch->ue_spec_bf_weights[layer]);
}
free(dlsch->txdataF);
free(dlsch->ue_spec_bf_weights);
free(dlsch);
*dlschptr = NULL;
......
......@@ -102,7 +102,10 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr, uint16_t N_RB_DL) {
for (int r=0; r<a_segments; r++) {
free16(dlsch->harq_processes[i]->c[r],1056);
dlsch->harq_processes[i]->c[r] = NULL;
nrLDPC_free_mem(dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]);
}
free16(dlsch->harq_processes[i]->c,a_segments);
free16(dlsch->harq_processes[i]->p_nrLDPC_procBuf,a_segments);
free16(dlsch->harq_processes[i],sizeof(NR_DL_UE_HARQ_t));
dlsch->harq_processes[i] = NULL;
......
......@@ -114,7 +114,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
LOG_D(PHY,"nr_ue_ulsch_procedures hard_id %d %d.%d\n",harq_pid,frame,slot);
uint32_t available_bits;
int16_t **tx_layers;
int32_t **txdataF;
int8_t Wf[2], Wt[2];
int l_prime[2], delta;
......@@ -123,7 +122,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
int sample_offsetF, N_RE_prime;
NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms;
NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][gNB_id];
int N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig
uint16_t number_dmrs_symbols = 0;
......@@ -253,7 +251,9 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
/////////////////////////ULSCH layer mapping/////////////////////////
///////////
tx_layers = (int16_t **)pusch_ue->txdataF_layers;
int16_t **tx_layers = (int16_t **)malloc16_clear(Nl*sizeof(int16_t *));
for (int nl=0; nl<Nl; nl++)
tx_layers[nl] = (int16_t *)malloc16_clear((available_bits<<1)/mod_order*sizeof(int16_t));
nr_ue_layer_mapping((int16_t *)d_mod,
Nl,
......@@ -336,6 +336,9 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
else
memcpy(y, tx_layers[0], (available_bits/mod_order)*sizeof(int32_t));
for (int nl = 0; nl < Nl; nl++)
free_and_zero(tx_layers[nl]);
free_and_zero(tx_layers);
/////////////////////////ULSCH RE mapping/////////////////////////
///////////
......
......@@ -225,11 +225,6 @@ typedef struct {
} NR_UE_COMMON_PER_THREAD;
typedef struct {
/// TX buffers for multiple layers
int32_t **txdataF_layers;
} NR_UE_PUSCH;
typedef struct {
bool active[2];
fapi_nr_ul_config_pucch_pdu pucch_pdu[2];
......@@ -819,7 +814,6 @@ typedef struct {
NR_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX];
NR_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_gNB_MAX];
NR_UE_SRS *srs_vars[NUMBER_OF_CONNECTED_gNB_MAX];
NR_UE_PUSCH *pusch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX];
NR_UE_PUCCH *pucch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX];
NR_UE_DLSCH_t *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX][NR_MAX_NB_LAYERS>4 ? 2:1]; // two RxTx Threads
NR_UE_ULSCH_t *ulsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX];
......
......@@ -395,19 +395,6 @@ int main(int argc, char **argv)
load_pbch_desc(pbch_file_fd);
}
/* for (int k=0; k<2; k++) {
// Create transport channel structures for 2 transport blocks (MIMO)
for (i=0; i<2; i++) {
gNB->dlsch[k][i] = new_gNB_dlsch(Kmimo,8,Nsoft,0,frame_parms,gNB_config);
if (!gNB->dlsch[k][i]) {
printf("Can't get eNB dlsch structures\n");
exit(-1);
}
gNB->dlsch[k][i]->Nsoft = 10;
gNB->dlsch[k][i]->rnti = n_rnti+k;
}
}*/
//configure UE
UE = malloc(sizeof(PHY_VARS_NR_UE));
memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS));
......@@ -434,8 +421,8 @@ int main(int argc, char **argv)
}
unsigned char harq_pid = 0; //dlsch->harq_ids[subframe];
processingData_L1tx_t msgDataTx;
init_DLSCH_struct(gNB, &msgDataTx);
processingData_L1tx_t msgDataTx;
init_DLSCH_struct(gNB, &msgDataTx);
NR_gNB_DLSCH_t *dlsch = msgDataTx.dlsch[0][0];
nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->harq_process.pdsch_pdu.pdsch_pdu_rel15;
//time_stats_t *rm_stats, *te_stats, *i_stats;
......@@ -642,8 +629,9 @@ int main(int argc, char **argv)
free(RC.gNB[0]);
free(RC.gNB);
int num_cw = NR_MAX_NB_LAYERS > 4? 2:1;
for (int sf = 0; sf < 2; sf++)
for (int i = 0; i < 2; i++)
for (int i = 0; i < num_cw; i++)
free_nr_ue_dlsch(&UE->dlsch[sf][0][i], N_RB_DL);
term_nr_ue_signal(UE, 1);
free(UE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment