Commit 80a6a3e8 authored by Rúben Soares da Silva's avatar Rúben Soares da Silva Committed by Robert Schmidt

Fix memory leak and improve convert_csirs_pdu()

- Remove calloc from convert_csirs_pdu function, change return value
  from 'nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *' to
  'nfapi_nr_dl_tti_csi_rs_pdu_rel15_t' to not require call to 'free()'
- Set parameter pointer as const as it's not modified
- Remove cast to fapi_nr_dl_config_csirs_pdu_rel15_t in csi_rx.c as
  ue->csirs_vars[gNB_id]->csirs_config_pdu is already of type
  fapi_nr_dl_config_csirs_pdu_rel15_t.
- Remove casted parameter in call to convert_csirs_pdu and replace with
  csirs_config_pdu obtained earlier from
  ue->csirs_vars[gNB_id]->csirs_config_pdu.
parent bba14188
...@@ -834,23 +834,23 @@ int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t r ...@@ -834,23 +834,23 @@ int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t r
return 0; return 0;
} }
nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *convert_csirs_pdu(fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu) static nfapi_nr_dl_tti_csi_rs_pdu_rel15_t convert_csirs_pdu(const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu)
{ {
nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *dl_tti_csi_rs_pdu = calloc(1, sizeof(nfapi_nr_dl_tti_csi_rs_pdu_rel15_t)); nfapi_nr_dl_tti_csi_rs_pdu_rel15_t dl_tti_csi_rs_pdu;
dl_tti_csi_rs_pdu->subcarrier_spacing = csirs_config_pdu->subcarrier_spacing; dl_tti_csi_rs_pdu.subcarrier_spacing = csirs_config_pdu->subcarrier_spacing;
dl_tti_csi_rs_pdu->cyclic_prefix = csirs_config_pdu->cyclic_prefix; dl_tti_csi_rs_pdu.cyclic_prefix = csirs_config_pdu->cyclic_prefix;
dl_tti_csi_rs_pdu->start_rb = csirs_config_pdu->start_rb; dl_tti_csi_rs_pdu.start_rb = csirs_config_pdu->start_rb;
dl_tti_csi_rs_pdu->nr_of_rbs = csirs_config_pdu->nr_of_rbs; dl_tti_csi_rs_pdu.nr_of_rbs = csirs_config_pdu->nr_of_rbs;
dl_tti_csi_rs_pdu->csi_type = csirs_config_pdu->csi_type; dl_tti_csi_rs_pdu.csi_type = csirs_config_pdu->csi_type;
dl_tti_csi_rs_pdu->row = csirs_config_pdu->row; dl_tti_csi_rs_pdu.row = csirs_config_pdu->row;
dl_tti_csi_rs_pdu->freq_domain = csirs_config_pdu->freq_domain; dl_tti_csi_rs_pdu.freq_domain = csirs_config_pdu->freq_domain;
dl_tti_csi_rs_pdu->symb_l0 = csirs_config_pdu->symb_l0; dl_tti_csi_rs_pdu.symb_l0 = csirs_config_pdu->symb_l0;
dl_tti_csi_rs_pdu->symb_l1 = csirs_config_pdu->symb_l1; dl_tti_csi_rs_pdu.symb_l1 = csirs_config_pdu->symb_l1;
dl_tti_csi_rs_pdu->cdm_type = csirs_config_pdu->cdm_type; dl_tti_csi_rs_pdu.cdm_type = csirs_config_pdu->cdm_type;
dl_tti_csi_rs_pdu->freq_density = csirs_config_pdu->freq_density; dl_tti_csi_rs_pdu.freq_density = csirs_config_pdu->freq_density;
dl_tti_csi_rs_pdu->scramb_id = csirs_config_pdu->scramb_id; dl_tti_csi_rs_pdu.scramb_id = csirs_config_pdu->scramb_id;
dl_tti_csi_rs_pdu->power_control_offset = csirs_config_pdu->power_control_offset; dl_tti_csi_rs_pdu.power_control_offset = csirs_config_pdu->power_control_offset;
dl_tti_csi_rs_pdu->power_control_offset_ss = csirs_config_pdu->power_control_offset_ss; dl_tti_csi_rs_pdu.power_control_offset_ss = csirs_config_pdu->power_control_offset_ss;
return dl_tti_csi_rs_pdu; return dl_tti_csi_rs_pdu;
} }
...@@ -862,7 +862,7 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t ...@@ -862,7 +862,7 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t
return; return;
} }
const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu = (fapi_nr_dl_config_csirs_pdu_rel15_t*)&ue->csirs_vars[gNB_id]->csirs_config_pdu; const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu = &ue->csirs_vars[gNB_id]->csirs_config_pdu;
#ifdef NR_CSIRS_DEBUG #ifdef NR_CSIRS_DEBUG
LOG_I(NR_PHY, "csirs_config_pdu->subcarrier_spacing = %i\n", csirs_config_pdu->subcarrier_spacing); LOG_I(NR_PHY, "csirs_config_pdu->subcarrier_spacing = %i\n", csirs_config_pdu->subcarrier_spacing);
...@@ -906,12 +906,12 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t ...@@ -906,12 +906,12 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t
uint8_t cqi = 0; uint8_t cqi = 0;
uint8_t i1[3]; uint8_t i1[3];
uint8_t i2[1]; uint8_t i2[1];
nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params = convert_csirs_pdu(csirs_config_pdu);
nr_generate_csi_rs(frame_parms, nr_generate_csi_rs(frame_parms,
ue->nr_csi_info->csi_rs_generated_signal, ue->nr_csi_info->csi_rs_generated_signal,
AMP, AMP,
ue->nr_csi_info, ue->nr_csi_info,
convert_csirs_pdu((fapi_nr_dl_config_csirs_pdu_rel15_t*)&ue->csirs_vars[gNB_id]->csirs_config_pdu), &csi_params,
proc->nr_slot_rx, proc->nr_slot_rx,
&N_cdm_groups, &N_cdm_groups,
&CDM_group_size, &CDM_group_size,
......
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