Commit c6bfb979 authored by Roberto Louro Magueta's avatar Roberto Louro Magueta

Remove calloc of report_tlv, prg_list and prgs

parent f7a34d42
......@@ -1702,7 +1702,7 @@ typedef struct {
typedef struct {
uint16_t num_prgs; // Number of PRBs to be reported for this SRS PDU. Value: 0 -> 272.
nfapi_nr_srs_reported_symbol_prgs_t *prg_list;
nfapi_nr_srs_reported_symbol_prgs_t prg_list[272];
} nfapi_nr_srs_reported_symbol_t;
typedef struct {
......@@ -1710,7 +1710,7 @@ typedef struct {
uint8_t num_symbols; // Number of symbols for SRS. Value: 1 -> 4. If a PHY does not report for individual symbols then this parameter should be set to 1.
uint8_t wide_band_snr; // SNR value in dB measured within configured SRS bandwidth on each symbol. Value: 0 -> 255 representing -64 dB to 63 dB with a step size 0.5 dB. 0xff will be set if this field is invalid.
uint8_t num_reported_symbols; // Number of symbols reported in this message. This allows PHY to report individual symbols or aggregated symbols where this field will be set to 1. Value: 1 -> 4.
nfapi_nr_srs_reported_symbol_t *prgs;
nfapi_nr_srs_reported_symbol_t prgs;
} nfapi_nr_srs_beamforming_report_t;
// SRS indication
......@@ -1728,7 +1728,7 @@ typedef struct {
int16_t timing_advance_offset_nsec; // Timing advance measured for the UE between the reference uplink time and the observed arrival time for the UE. Value: -16800 … +16800 nanoseconds. 0xffff should be set if this field is invalid.
uint8_t srs_usage; // 0 – beamManagement; 1 – codebook; 2 – nonCodebook; 3 – antennaSwitching; 4 – 255: reserved; Note: This field matches the SRS usage field of the SRS PDU to which this report is linked.
uint8_t report_type; // The type of report included in or pointed to by Report TLV depends on the SRS usage: Beam management (1: Beamforming report); Codebook (1: Normalized Channel I/Q Matrix); nonCodebook (1: Normalized Channel I/Q Matrix); antennaSwitch (1: Channel SVD Representation); all (0: null report)
nfapi_srs_report_tlv_t *report_tlv;
nfapi_srs_report_tlv_t report_tlv;
} nfapi_nr_srs_indication_pdu_t;
typedef struct {
......
......@@ -3162,7 +3162,7 @@ int pack_nr_srs_beamforming_report(void *pMessageBuf, void *pPackedBuf, uint32_t
return 0;
}
if(!pack_nr_srs_reported_symbol(nr_srs_beamforming_report->prgs, &pWritePackedMessage, end)) {
if (!pack_nr_srs_reported_symbol(&nr_srs_beamforming_report->prgs, &pWritePackedMessage, end)) {
return 0;
}
......@@ -3199,7 +3199,7 @@ static uint8_t pack_nr_srs_indication_body(nfapi_nr_srs_indication_pdu_t *value,
return 0;
}
if(!pack_nr_srs_report_tlv(value->report_tlv,ppWritePackedMsg, end)) {
if (!pack_nr_srs_report_tlv(&value->report_tlv, ppWritePackedMsg, end)) {
return 0;
}
......@@ -5920,10 +5920,6 @@ static uint8_t unpack_nr_srs_reported_symbol(nfapi_nr_srs_reported_symbol_t *prg
return 0;
}
if(!prgs->prg_list) {
prgs->prg_list = (nfapi_nr_srs_reported_symbol_prgs_t*) calloc(1, prgs->num_prgs*sizeof(nfapi_nr_srs_reported_symbol_prgs_t));
}
for(int i = 0; i < prgs->num_prgs; i++) {
if (!pull8(ppReadPackedMsg, &prgs->prg_list[i].rb_snr, end)) {
return 0;
......@@ -5948,11 +5944,7 @@ int unpack_nr_srs_beamforming_report(void *pMessageBuf, uint32_t messageBufLen,
return -1;
}
if(!nr_srs_beamforming_report->prgs) {
nr_srs_beamforming_report->prgs = (nfapi_nr_srs_reported_symbol_t*) calloc(1, sizeof(nfapi_nr_srs_reported_symbol_t));
}
if(!unpack_nr_srs_reported_symbol(nr_srs_beamforming_report->prgs, &pReadPackedMessage, end)) {
if (!unpack_nr_srs_reported_symbol(&nr_srs_beamforming_report->prgs, &pReadPackedMessage, end)) {
return -1;
}
......@@ -5986,7 +5978,7 @@ static uint8_t unpack_nr_srs_indication_body(nfapi_nr_srs_indication_pdu_t *valu
return 0;
}
if(!unpack_nr_srs_report_tlv(value->report_tlv, ppReadPackedMsg, end)) {
if (!unpack_nr_srs_report_tlv(&value->report_tlv, ppReadPackedMsg, end)) {
return 0;
}
......
......@@ -605,11 +605,6 @@ int fill_srs_reported_symbol_list(nfapi_nr_srs_reported_symbol_t *prgs,
const int srs_est) {
prgs->num_prgs = srs_pdu->beamforming.num_prgs;
if (!prgs->prg_list) {
prgs->prg_list = (nfapi_nr_srs_reported_symbol_prgs_t*) calloc(1, N_RB_UL*sizeof(nfapi_nr_srs_reported_symbol_prgs_t));
}
for(int prg_idx = 0; prg_idx < prgs->num_prgs; prg_idx++) {
if (srs_est<0) {
prgs->prg_list[prg_idx].rb_snr = 0xFF;
......@@ -966,11 +961,9 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
LOG_I(NR_PHY, "srs_indication->report_type = %i\n", srs_indication->report_type);
#endif
if (!srs_indication->report_tlv) {
srs_indication->report_tlv = (nfapi_srs_report_tlv_t *)calloc(1, sizeof(nfapi_srs_report_tlv_t));
}
srs_indication->report_tlv->tag = 0;
srs_indication->report_tlv->length = 0;
nfapi_srs_report_tlv_t *report_tlv = &srs_indication->report_tlv;
report_tlv->tag = 0;
report_tlv->length = 0;
start_meas(&gNB->srs_report_tlv_stats);
switch (srs_indication->srs_usage) {
......@@ -981,8 +974,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
nr_srs_bf_report.num_symbols = 1 << srs_pdu->num_symbols;
nr_srs_bf_report.wide_band_snr = srs_est >= 0 ? (snr + 64) << 1 : 0xFF; // 0xFF will be set if this field is invalid
nr_srs_bf_report.num_reported_symbols = 1 << srs_pdu->num_symbols;
nr_srs_bf_report.prgs = (nfapi_nr_srs_reported_symbol_t *)calloc(1, nr_srs_bf_report.num_reported_symbols * sizeof(nfapi_nr_srs_reported_symbol_t));
fill_srs_reported_symbol_list(&nr_srs_bf_report.prgs[0], srs_pdu, frame_parms->N_RB_UL, snr_per_rb, srs_est);
fill_srs_reported_symbol_list(&nr_srs_bf_report.prgs, srs_pdu, frame_parms->N_RB_UL, snr_per_rb, srs_est);
#ifdef SRS_IND_DEBUG
LOG_I(NR_PHY, "nr_srs_bf_report.prg_size = %i\n", nr_srs_bf_report.prg_size);
......@@ -999,7 +991,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
}
#endif
srs_indication->report_tlv->length = pack_nr_srs_beamforming_report(&nr_srs_bf_report, srs_indication->report_tlv->value, 16384 * sizeof(uint32_t));
report_tlv->length = pack_nr_srs_beamforming_report(&nr_srs_bf_report, report_tlv->value, sizeof(report_tlv->value));
stop_meas(&gNB->srs_beam_report_stats);
break;
}
......@@ -1048,9 +1040,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
}
#endif
srs_indication->report_tlv->length = pack_nr_srs_normalized_channel_iq_matrix(&nr_srs_channel_iq_matrix,
srs_indication->report_tlv->value,
16384 * sizeof(uint32_t));
report_tlv->length = pack_nr_srs_normalized_channel_iq_matrix(&nr_srs_channel_iq_matrix, report_tlv->value, sizeof(report_tlv->value));
stop_meas(&gNB->srs_iq_matrix_stats);
break;
}
......@@ -1066,10 +1056,10 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
stop_meas(&gNB->srs_report_tlv_stats);
#ifdef SRS_IND_DEBUG
LOG_I(NR_PHY, "srs_indication->report_tlv->tag = %i\n", srs_indication->report_tlv->tag);
LOG_I(NR_PHY, "srs_indication->report_tlv->length = %i\n", srs_indication->report_tlv->length);
char *value = (char *)srs_indication->report_tlv->value;
for (int b = 0; b < srs_indication->report_tlv->length; b++) {
LOG_I(NR_PHY, "report_tlv->tag = %i\n", report_tlv->tag);
LOG_I(NR_PHY, "report_tlv->length = %i\n", report_tlv->length);
char *value = (char *)report_tlv->value;
for (int b = 0; b < report_tlv->length; b++) {
LOG_I(NR_PHY, "value[%i] = 0x%02x\n", b, value[b] & 0xFF);
}
#endif
......
......@@ -1151,7 +1151,7 @@ int nr_srs_tpmi_estimation(const NR_PUSCH_Config_t *pusch_Config,
void handle_nr_srs_measurements(const module_id_t module_id,
const frame_t frame,
const sub_frame_t slot,
const nfapi_nr_srs_indication_pdu_t *srs_ind)
nfapi_nr_srs_indication_pdu_t *srs_ind)
{
LOG_D(NR_MAC, "(%d.%d) Received SRS indication for UE %04x\n", frame, slot, srs_ind->rnti);
......@@ -1178,12 +1178,13 @@ void handle_nr_srs_measurements(const module_id_t module_id,
gNB_MAC_INST *nr_mac = RC.nrmac[module_id];
NR_mac_stats_t *stats = &UE->mac_stats;
nfapi_srs_report_tlv_t *report_tlv = &srs_ind->report_tlv;
switch (srs_ind->srs_usage) {
case NR_SRS_ResourceSet__usage_beamManagement: {
nfapi_nr_srs_beamforming_report_t nr_srs_bf_report;
unpack_nr_srs_beamforming_report(srs_ind->report_tlv->value,
srs_ind->report_tlv->length,
unpack_nr_srs_beamforming_report(report_tlv->value,
report_tlv->length,
&nr_srs_bf_report,
sizeof(nfapi_nr_srs_beamforming_report_t));
......@@ -1214,10 +1215,10 @@ void handle_nr_srs_measurements(const module_id_t module_id,
const int ul_prbblack_SNR_threshold = nr_mac->ul_prbblack_SNR_threshold;
uint16_t *ulprbbl = nr_mac->ulprbbl;
uint16_t num_rbs = nr_srs_bf_report.prg_size * nr_srs_bf_report.prgs[0].num_prgs;
uint16_t num_rbs = nr_srs_bf_report.prg_size * nr_srs_bf_report.prgs.num_prgs;
memset(ulprbbl, 0, num_rbs * sizeof(uint16_t));
for (int rb = 0; rb < num_rbs; rb++) {
int snr = (nr_srs_bf_report.prgs[0].prg_list[rb / nr_srs_bf_report.prg_size].rb_snr >> 1) - 64;
int snr = (nr_srs_bf_report.prgs.prg_list[rb / nr_srs_bf_report.prg_size].rb_snr >> 1) - 64;
if (snr < wide_band_snr_dB - ul_prbblack_SNR_threshold) {
ulprbbl[rb] = 0x3FFF; // all symbols taken
}
......@@ -1229,8 +1230,8 @@ void handle_nr_srs_measurements(const module_id_t module_id,
case NR_SRS_ResourceSet__usage_codebook: {
nfapi_nr_srs_normalized_channel_iq_matrix_t nr_srs_channel_iq_matrix;
unpack_nr_srs_normalized_channel_iq_matrix(srs_ind->report_tlv->value,
srs_ind->report_tlv->length,
unpack_nr_srs_normalized_channel_iq_matrix(report_tlv->value,
report_tlv->length,
&nr_srs_channel_iq_matrix,
sizeof(nfapi_nr_srs_normalized_channel_iq_matrix_t));
......
......@@ -446,7 +446,7 @@ void handle_nr_ul_harq(const int CC_idP,
void handle_nr_srs_measurements(const module_id_t module_id,
const frame_t frame,
const sub_frame_t slot,
const nfapi_nr_srs_indication_pdu_t *srs_ind);
nfapi_nr_srs_indication_pdu_t *srs_ind);
int16_t ssb_index_from_prach(module_id_t module_idP,
frame_t frameP,
......
......@@ -231,15 +231,15 @@ void handle_nr_srs(NR_UL_IND_t *UL_info) {
const frame_t frame = UL_info->srs_ind.sfn;
const sub_frame_t slot = UL_info->srs_ind.slot;
const int num_srs = UL_info->srs_ind.number_of_pdus;
const nfapi_nr_srs_indication_pdu_t *srs_list = UL_info->srs_ind.pdu_list;
nfapi_nr_srs_indication_pdu_t *srs_list = UL_info->srs_ind.pdu_list;
for (int i = 0; i < num_srs; i++) {
const nfapi_nr_srs_indication_pdu_t *srs_ind = &srs_list[i];
nfapi_nr_srs_indication_pdu_t *srs_ind = &srs_list[i];
LOG_D(NR_PHY, "(%d.%d) UL_info->srs_ind.pdu_list[%d].rnti: 0x%04x\n", frame, slot, i, srs_ind->rnti);
handle_nr_srs_measurements(module_id,
frame,
slot,
&srs_list[i]);
srs_ind);
}
UL_info->srs_ind.number_of_pdus = 0;
......
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