diff --git a/common/utils/nr/nr_common.h b/common/utils/nr/nr_common.h index 8cd210dec8..858ccd4109 100644 --- a/common/utils/nr/nr_common.h +++ b/common/utils/nr/nr_common.h @@ -82,7 +82,7 @@ int get_dmrs_port(int nl, uint16_t dmrs_ports); uint16_t SL_to_bitmap(int startSymbolIndex, int nrOfSymbols); int get_nb_periods_per_frame(uint8_t tdd_period); int get_supported_band_index(int scs, int band, int n_rbs); -long rrc_get_max_nr_csrs(uint8_t max_rbs, long b_SRS); +long rrc_get_max_nr_csrs(const int max_rbs, long b_SRS); void get_samplerate_and_bw(int mu, int n_rb, int8_t threequarter_fs, diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h index d2cd9d7a9f..97abfbbe4c 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h @@ -1691,7 +1691,7 @@ typedef struct { uint16_t num_ue_srs_ports; // Nu: Number of sampled UE SRS ports. Value: 07 uint16_t prg_size; // Size in RBs of a precoding resource block group (PRG) – to which the same digital beamforming gets applied. Value: 1->272 uint16_t num_prgs; // Number of PRGs Np to be reported for this SRS PDU. Value: 0-> 272 - uint8_t channel_matrix[272*512*8*4]; // Array of (numPRGs*Nu*Ng) entries of the type denoted by iqRepresentation H{PRG pI} [ueAntenna uI, gNB antenna gI] = array[uI*Ng*Np + gI*Np + pI]; uI: 0…Nu-1 (UE antenna index); gI: 0…Ng-1 (gNB antenna index); pI: 0…Np-1 (PRG index) + uint8_t channel_matrix[272*2*8*4]; // Array of (numPRGs*Nu*Ng) entries of the type denoted by iqRepresentation H{PRG pI} [ueAntenna uI, gNB antenna gI] = array[uI*Ng*Np + gI*Np + pI]; uI: 0…Nu-1 (UE antenna index); gI: 0…Ng-1 (gNB antenna index); pI: 0…Np-1 (PRG index) } nfapi_nr_srs_normalized_channel_iq_matrix_t; // Beamforming report @@ -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 { diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c index e183736578..7cce8fbea4 100644 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c @@ -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; } diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 04ece4f0d9..0f2f41c470 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -742,6 +742,14 @@ typedef struct PHY_VARS_gNB_s { time_stats_t ulsch_rbs_extraction_stats; time_stats_t ulsch_mrc_stats; time_stats_t ulsch_llr_stats; + time_stats_t rx_srs_stats; + time_stats_t generate_srs_stats; + time_stats_t get_srs_signal_stats; + time_stats_t srs_channel_estimation_stats; + time_stats_t srs_timing_advance_stats; + time_stats_t srs_report_tlv_stats; + time_stats_t srs_beam_report_stats; + time_stats_t srs_iq_matrix_stats; /* time_stats_t rx_dft_stats; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index fe0397970b..6529037a33 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -206,6 +206,7 @@ typedef struct { uint8_t k_0_p[MAX_NUM_NR_SRS_AP][MAX_NUM_NR_SRS_SYMBOLS]; uint8_t srs_generated_signal_bits; int32_t **srs_generated_signal; + nfapi_nr_srs_pdu_t srs_pdu; } nr_srs_info_t; typedef struct { diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 7bb81f97ef..38e1cfd3b4 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -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; @@ -675,6 +670,20 @@ int fill_srs_channel_matrix(uint8_t *channel_matrix, return 0; } +int check_srs_pdu(const nfapi_nr_srs_pdu_t *srs_pdu, nfapi_nr_srs_pdu_t *saved_srs_pdu) +{ + if (saved_srs_pdu->bwp_start == srs_pdu->bwp_start && + saved_srs_pdu->bwp_size == srs_pdu->bwp_size && + saved_srs_pdu->num_ant_ports == srs_pdu->num_ant_ports && + saved_srs_pdu->time_start_position == srs_pdu->time_start_position && + saved_srs_pdu->num_symbols == srs_pdu->num_symbols && + saved_srs_pdu->config_index == srs_pdu->config_index) { + return 1; + } + *saved_srs_pdu = *srs_pdu; + return 0; +} + int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { /* those variables to log T_GNB_PHY_PUCCH_PUSCH_IQ only when we try to decode */ int pucch_decode_done = 0; @@ -867,6 +876,8 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { if ((srs->active == 1) && (srs->frame == frame_rx) && (srs->slot == slot_rx)) { LOG_D(NR_PHY, "(%d.%d) gNB is waiting for SRS, id = %i\n", frame_rx, slot_rx, i); + start_meas(&gNB->rx_srs_stats); + NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; nfapi_nr_srs_pdu_t *srs_pdu = &srs->srs_pdu; uint8_t N_symb_SRS = 1 << srs_pdu->num_symbols; @@ -877,10 +888,18 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { int8_t snr_per_rb[srs_pdu->bwp_size]; int8_t snr; - generate_srs_nr(srs_pdu, frame_parms, gNB->nr_srs_info[i]->srs_generated_signal, 0, gNB->nr_srs_info[i], AMP, frame_rx, slot_rx); + start_meas(&gNB->generate_srs_stats); + if (check_srs_pdu(srs_pdu, &gNB->nr_srs_info[i]->srs_pdu) == 0) { + generate_srs_nr(srs_pdu, frame_parms, gNB->nr_srs_info[i]->srs_generated_signal, 0, gNB->nr_srs_info[i], AMP, frame_rx, slot_rx); + } + stop_meas(&gNB->generate_srs_stats); + + start_meas(&gNB->get_srs_signal_stats); int srs_est = nr_get_srs_signal(gNB, frame_rx, slot_rx, srs_pdu, gNB->nr_srs_info[i], srs_received_signal); + stop_meas(&gNB->get_srs_signal_stats); if (srs_est >= 0) { + start_meas(&gNB->srs_channel_estimation_stats); nr_srs_channel_estimation(gNB, frame_rx, slot_rx, @@ -893,6 +912,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { srs_estimated_channel_time_shifted, snr_per_rb, &snr); + stop_meas(&gNB->srs_channel_estimation_stats); } if ((snr * 10) < gNB->srs_thres) { @@ -922,7 +942,9 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { nfapi_nr_srs_indication_pdu_t *srs_indication = &gNB->srs_pdu_list[gNB->UL_INFO.srs_ind.number_of_pdus]; srs_indication->handle = srs_pdu->handle; srs_indication->rnti = srs_pdu->rnti; + start_meas(&gNB->srs_timing_advance_stats); srs_indication->timing_advance_offset = srs_est >= 0 ? nr_est_timing_advance_srs(frame_parms, srs_estimated_channel_time[0]) : 0xFFFF; + stop_meas(&gNB->srs_timing_advance_stats); srs_indication->timing_advance_offset_nsec = srs_est >= 0 ? (int16_t)((((int32_t)srs_indication->timing_advance_offset - 31) * ((int32_t)TC_NSEC_x32768)) >> 15) : 0xFFFF; switch (srs_pdu->srs_parameters_v4.usage) { case 0: @@ -955,88 +977,87 @@ 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) { case NR_SRS_ResourceSet__usage_beamManagement: { - nfapi_nr_srs_beamforming_report_t nr_srs_beamforming_report; - nr_srs_beamforming_report.prg_size = srs_pdu->beamforming.prg_size; - nr_srs_beamforming_report.num_symbols = 1 << srs_pdu->num_symbols; - nr_srs_beamforming_report.wide_band_snr = srs_est >= 0 ? (snr + 64) << 1 : 0xFF; // 0xFF will be set if this field is invalid - nr_srs_beamforming_report.num_reported_symbols = 1 << srs_pdu->num_symbols; - nr_srs_beamforming_report.prgs = (nfapi_nr_srs_reported_symbol_t *)calloc(1, nr_srs_beamforming_report.num_reported_symbols * sizeof(nfapi_nr_srs_reported_symbol_t)); - fill_srs_reported_symbol_list(&nr_srs_beamforming_report.prgs[0], srs_pdu, frame_parms->N_RB_UL, snr_per_rb, srs_est); + start_meas(&gNB->srs_beam_report_stats); + nfapi_nr_srs_beamforming_report_t nr_srs_bf_report; + nr_srs_bf_report.prg_size = srs_pdu->beamforming.prg_size; + 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; + 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_beamforming_report.prg_size = %i\n", nr_srs_beamforming_report.prg_size); - LOG_I(NR_PHY, "nr_srs_beamforming_report.num_symbols = %i\n", nr_srs_beamforming_report.num_symbols); - LOG_I(NR_PHY, "nr_srs_beamforming_report.wide_band_snr = %i (%i dB)\n", nr_srs_beamforming_report.wide_band_snr, (nr_srs_beamforming_report.wide_band_snr >> 1) - 64); - LOG_I(NR_PHY, "nr_srs_beamforming_report.num_reported_symbols = %i\n", nr_srs_beamforming_report.num_reported_symbols); - LOG_I(NR_PHY, "nr_srs_beamforming_report.prgs[0].num_prgs = %i\n", nr_srs_beamforming_report.prgs[0].num_prgs); - for (int prg_idx = 0; prg_idx < nr_srs_beamforming_report.prgs[0].num_prgs; prg_idx++) { + LOG_I(NR_PHY, "nr_srs_bf_report.prg_size = %i\n", nr_srs_bf_report.prg_size); + LOG_I(NR_PHY, "nr_srs_bf_report.num_symbols = %i\n", nr_srs_bf_report.num_symbols); + LOG_I(NR_PHY, "nr_srs_bf_report.wide_band_snr = %i (%i dB)\n", nr_srs_bf_report.wide_band_snr, (nr_srs_bf_report.wide_band_snr >> 1) - 64); + LOG_I(NR_PHY, "nr_srs_bf_report.num_reported_symbols = %i\n", nr_srs_bf_report.num_reported_symbols); + LOG_I(NR_PHY, "nr_srs_bf_report.prgs[0].num_prgs = %i\n", nr_srs_bf_report.prgs[0].num_prgs); + for (int prg_idx = 0; prg_idx < nr_srs_bf_report.prgs[0].num_prgs; prg_idx++) { LOG_I(NR_PHY, "nr_srs_beamforming_report.prgs[0].prg_list[%3i].rb_snr = %i (%i dB)\n", prg_idx, - nr_srs_beamforming_report.prgs[0].prg_list[prg_idx].rb_snr, - (nr_srs_beamforming_report.prgs[0].prg_list[prg_idx].rb_snr >> 1) - 64); + nr_srs_bf_report.prgs[0].prg_list[prg_idx].rb_snr, + (nr_srs_bf_report.prgs[0].prg_list[prg_idx].rb_snr >> 1) - 64); } #endif - srs_indication->report_tlv->length = pack_nr_srs_beamforming_report(&nr_srs_beamforming_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; } case NR_SRS_ResourceSet__usage_codebook: { - nfapi_nr_srs_normalized_channel_iq_matrix_t nr_srs_normalized_channel_iq_matrix; - nr_srs_normalized_channel_iq_matrix.normalized_iq_representation = srs_pdu->srs_parameters_v4.iq_representation; - nr_srs_normalized_channel_iq_matrix.num_gnb_antenna_elements = gNB->frame_parms.nb_antennas_rx; - nr_srs_normalized_channel_iq_matrix.num_ue_srs_ports = srs_pdu->srs_parameters_v4.num_total_ue_antennas; - nr_srs_normalized_channel_iq_matrix.prg_size = srs_pdu->srs_parameters_v4.prg_size; - nr_srs_normalized_channel_iq_matrix.num_prgs = srs_pdu->srs_parameters_v4.srs_bandwidth_size / srs_pdu->srs_parameters_v4.prg_size; - fill_srs_channel_matrix(nr_srs_normalized_channel_iq_matrix.channel_matrix, + start_meas(&gNB->srs_iq_matrix_stats); + nfapi_nr_srs_normalized_channel_iq_matrix_t nr_srs_channel_iq_matrix; + nr_srs_channel_iq_matrix.normalized_iq_representation = srs_pdu->srs_parameters_v4.iq_representation; + nr_srs_channel_iq_matrix.num_gnb_antenna_elements = gNB->frame_parms.nb_antennas_rx; + nr_srs_channel_iq_matrix.num_ue_srs_ports = srs_pdu->srs_parameters_v4.num_total_ue_antennas; + nr_srs_channel_iq_matrix.prg_size = srs_pdu->srs_parameters_v4.prg_size; + nr_srs_channel_iq_matrix.num_prgs = srs_pdu->srs_parameters_v4.srs_bandwidth_size / srs_pdu->srs_parameters_v4.prg_size; + fill_srs_channel_matrix(nr_srs_channel_iq_matrix.channel_matrix, srs_pdu, gNB->nr_srs_info[i], - nr_srs_normalized_channel_iq_matrix.normalized_iq_representation, - nr_srs_normalized_channel_iq_matrix.num_gnb_antenna_elements, - nr_srs_normalized_channel_iq_matrix.num_ue_srs_ports, - nr_srs_normalized_channel_iq_matrix.prg_size, - nr_srs_normalized_channel_iq_matrix.num_prgs, + nr_srs_channel_iq_matrix.normalized_iq_representation, + nr_srs_channel_iq_matrix.num_gnb_antenna_elements, + nr_srs_channel_iq_matrix.num_ue_srs_ports, + nr_srs_channel_iq_matrix.prg_size, + nr_srs_channel_iq_matrix.num_prgs, &gNB->frame_parms, srs_estimated_channel_freq); #ifdef SRS_IND_DEBUG - LOG_I(NR_PHY, "nr_srs_normalized_channel_iq_matrix.normalized_iq_representation = %i\n", nr_srs_normalized_channel_iq_matrix.normalized_iq_representation); - LOG_I(NR_PHY, "nr_srs_normalized_channel_iq_matrix.num_gnb_antenna_elements = %i\n", nr_srs_normalized_channel_iq_matrix.num_gnb_antenna_elements); - LOG_I(NR_PHY, "nr_srs_normalized_channel_iq_matrix.num_ue_srs_ports = %i\n", nr_srs_normalized_channel_iq_matrix.num_ue_srs_ports); - LOG_I(NR_PHY, "nr_srs_normalized_channel_iq_matrix.prg_size = %i\n", nr_srs_normalized_channel_iq_matrix.prg_size); - LOG_I(NR_PHY, "nr_srs_normalized_channel_iq_matrix.num_prgs = %i\n", nr_srs_normalized_channel_iq_matrix.num_prgs); - c16_t *channel_matrix16 = (c16_t *)nr_srs_normalized_channel_iq_matrix.channel_matrix; - c8_t *channel_matrix8 = (c8_t *)nr_srs_normalized_channel_iq_matrix.channel_matrix; - for (int uI = 0; uI < nr_srs_normalized_channel_iq_matrix.num_ue_srs_ports; uI++) { - for (int gI = 0; gI < nr_srs_normalized_channel_iq_matrix.num_gnb_antenna_elements; gI++) { - for (int pI = 0; pI < nr_srs_normalized_channel_iq_matrix.num_prgs; pI++) { + LOG_I(NR_PHY, "nr_srs_channel_iq_matrix.normalized_iq_representation = %i\n", nr_srs_channel_iq_matrix.normalized_iq_representation); + LOG_I(NR_PHY, "nr_srs_channel_iq_matrix.num_gnb_antenna_elements = %i\n", nr_srs_channel_iq_matrix.num_gnb_antenna_elements); + LOG_I(NR_PHY, "nr_srs_channel_iq_matrix.num_ue_srs_ports = %i\n", nr_srs_channel_iq_matrix.num_ue_srs_ports); + LOG_I(NR_PHY, "nr_srs_channel_iq_matrix.prg_size = %i\n", nr_srs_channel_iq_matrix.prg_size); + LOG_I(NR_PHY, "nr_srs_channel_iq_matrix.num_prgs = %i\n", nr_srs_channel_iq_matrix.num_prgs); + c16_t *channel_matrix16 = (c16_t *)nr_srs_channel_iq_matrix.channel_matrix; + c8_t *channel_matrix8 = (c8_t *)nr_srs_channel_iq_matrix.channel_matrix; + for (int uI = 0; uI < nr_srs_channel_iq_matrix.num_ue_srs_ports; uI++) { + for (int gI = 0; gI < nr_srs_channel_iq_matrix.num_gnb_antenna_elements; gI++) { + for (int pI = 0; pI < nr_srs_channel_iq_matrix.num_prgs; pI++) { uint16_t index = - uI * nr_srs_normalized_channel_iq_matrix.num_gnb_antenna_elements * nr_srs_normalized_channel_iq_matrix.num_prgs + gI * nr_srs_normalized_channel_iq_matrix.num_prgs + pI; + uI * nr_srs_channel_iq_matrix.num_gnb_antenna_elements * nr_srs_channel_iq_matrix.num_prgs + gI * nr_srs_channel_iq_matrix.num_prgs + pI; LOG_I(NR_PHY, "(uI %i, gI %i, pI %i) channel_matrix --> real %i, imag %i\n", uI, gI, pI, - nr_srs_normalized_channel_iq_matrix.normalized_iq_representation == 0 ? channel_matrix8[index].r : channel_matrix16[index].r, - nr_srs_normalized_channel_iq_matrix.normalized_iq_representation == 0 ? channel_matrix8[index].i : channel_matrix16[index].i); + nr_srs_channel_iq_matrix.normalized_iq_representation == 0 ? channel_matrix8[index].r : channel_matrix16[index].r, + nr_srs_channel_iq_matrix.normalized_iq_representation == 0 ? channel_matrix8[index].i : channel_matrix16[index].i); } } } #endif - srs_indication->report_tlv->length = pack_nr_srs_normalized_channel_iq_matrix(&nr_srs_normalized_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; } @@ -1048,18 +1069,21 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { default: AssertFatal(1 == 0, "Invalid SRS usage\n"); } + 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 gNB->UL_INFO.srs_ind.number_of_pdus += 1; srs->active = 0; + + stop_meas(&gNB->rx_srs_stats); } } } diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 071c04d498..cd776b009d 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -278,6 +278,7 @@ int main(int argc, char **argv) double snr_step = .2; uint8_t snr1set = 0; int slot = 8, frame = 1; + int do_SRS = 0; FILE *output_fd = NULL; double **s_re,**s_im,**r_re,**r_im; //uint8_t write_output_file = 0; @@ -354,7 +355,7 @@ int main(int argc, char **argv) /* initialize the sin-cos table */ InitSinLUT(); - while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:i:kl:m:n:op:q:r:s:t:u:v:w:y:z:C:F:G:H:I:M:N:PR:S:T:U:L:ZW:")) != -1) { + while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:i:kl:m:n:op:q:r:s:t:u:v:w:y:z:C:F:G:H:I:M:N:PR:S:T:U:L:ZW:E:")) != -1) { printf("handling optarg %c\n",c); switch (c) { @@ -618,6 +619,18 @@ int main(int argc, char **argv) printf("NOTE: TRANSFORM PRECODING (SC-FDMA) is ENABLED in UPLINK (0 - ENABLE, 1 - DISABLE) : %d \n", transform_precoding); break; + case 'E': + do_SRS = atoi(optarg); + if (do_SRS == 0) { + printf("SRS disabled\n"); + } else if (do_SRS == 1) { + printf("SRS enabled\n"); + } else { + printf("Invalid SRS option. SRS disabled.\n"); + do_SRS = 0; + } + break; + default: case 'h': printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -i Intefrence0 -j Interference1 -n n_frames -s snr0 -S snr1 -t Delayspread -x transmission_mode -y TXant -z RXant -A interpolation_file -C(alibration offset dB) -N CellId -Z Enable SC-FDMA in Uplink \n", argv[0]); @@ -659,6 +672,7 @@ int main(int argc, char **argv) printf("-Q If -F used, read parameters from file\n"); printf("-Z If -Z is used, SC-FDMA or transform precoding is enabled in Uplink \n"); printf("-W Num of layer for PUSCH\n"); + printf("-E {SRS: [0] Disabled, [1] Enabled} e.g. -E 1\n"); exit(-1); break; @@ -803,7 +817,7 @@ int main(int argc, char **argv) maxDoppler, corr_level, 0, - 0, + delay, 0, 0); @@ -868,8 +882,6 @@ int main(int argc, char **argv) memset((void*)Sched_INFO,0,sizeof(*Sched_INFO)); Sched_INFO->UL_tti_req=UL_tti_req; - nfapi_nr_pusch_pdu_t *pusch_pdu = &UL_tti_req->pdus_list[0].pusch_pdu; - nr_phy_data_tx_t phy_data = {0}; unsigned char *estimated_output_bit; @@ -1081,6 +1093,14 @@ int main(int argc, char **argv) reset_meas(&UE->ulsch_rate_matching_stats); reset_meas(&UE->ulsch_interleaving_stats); reset_meas(&UE->ulsch_encoding_stats); + reset_meas(&gNB->rx_srs_stats); + reset_meas(&gNB->generate_srs_stats); + reset_meas(&gNB->get_srs_signal_stats); + reset_meas(&gNB->srs_channel_estimation_stats); + reset_meas(&gNB->srs_timing_advance_stats); + reset_meas(&gNB->srs_report_tlv_stats); + reset_meas(&gNB->srs_beam_report_stats); + reset_meas(&gNB->srs_iq_matrix_stats); uint32_t errors_scrambling[16] = {0}; int n_errors[16] = {0}; @@ -1090,23 +1110,27 @@ int main(int argc, char **argv) clear_pusch_stats(gNB); for (trial = 0; trial < n_trials; trial++) { + uint8_t round = 0; crc_status = 1; errors_decoding = 0; + while (round < max_rounds && crc_status) { + round_trials[round]++; - UE->ul_harq_processes[harq_pid].round = round; rv_index = nr_rv_round_map[round % 4]; - UE_proc.nr_slot_tx = slot; - UE_proc.frame_tx = frame; - UE_proc.gNB_id = 0; + /// gNB UL PDUs UL_tti_req->SFN = frame; UL_tti_req->Slot = slot; - UL_tti_req->n_pdus = 1; - UL_tti_req->pdus_list[0].pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE; - UL_tti_req->pdus_list[0].pdu_size = sizeof(nfapi_nr_pusch_pdu_t); + UL_tti_req->n_pdus = do_SRS == 1 ? 2 : 1; + + nfapi_nr_ul_tti_request_number_of_pdus_t *pdu_element0 = &UL_tti_req->pdus_list[0]; + pdu_element0->pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE; + pdu_element0->pdu_size = sizeof(nfapi_nr_pusch_pdu_t); + + nfapi_nr_pusch_pdu_t *pusch_pdu = &pdu_element0->pusch_pdu; memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); int abwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275); @@ -1168,6 +1192,42 @@ int main(int argc, char **argv) pusch_pdu->num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; } + if (do_SRS == 1) { + const uint16_t m_SRS[64] = { 4, 8, 12, 16, 16, 20, 24, 24, 28, 32, 36, 40, 48, 48, 52, 56, 60, 64, 72, 72, 76, 80, 88, + 96, 96, 104, 112, 120, 120, 120, 128, 128, 128, 132, 136, 144, 144, 144, 144, 152, 160, + 160, 160, 168, 176, 184, 192, 192, 192, 192, 208, 216, 224, 240, 240, 240, 240, 256, 256, + 256, 264, 272, 272, 272 }; + nfapi_nr_ul_tti_request_number_of_pdus_t *pdu_element1 = &UL_tti_req->pdus_list[1]; + pdu_element1->pdu_type = NFAPI_NR_UL_CONFIG_SRS_PDU_TYPE; + pdu_element1->pdu_size = sizeof(nfapi_nr_srs_pdu_t); + nfapi_nr_srs_pdu_t *srs_pdu = &pdu_element1->srs_pdu; + memset(srs_pdu, 0, sizeof(nfapi_nr_srs_pdu_t)); + srs_pdu->rnti = n_rnti; + srs_pdu->bwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275); + srs_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275); + srs_pdu->subcarrier_spacing = frame_parms->subcarrier_spacing; + srs_pdu->num_ant_ports = n_tx == 4 ? 2 : n_tx == 2 ? 1 : 0; + srs_pdu->sequence_id = 40; + srs_pdu->config_index = rrc_get_max_nr_csrs(srs_pdu->bwp_size, srs_pdu->bandwidth_index); + srs_pdu->resource_type = NR_SRS_Resource__resourceType_PR_periodic; + srs_pdu->t_srs = 1; + srs_pdu->srs_parameters_v4.srs_bandwidth_size = m_SRS[srs_pdu->config_index]; + srs_pdu->srs_parameters_v4.usage = 1 << NR_SRS_ResourceSet__usage_codebook; + srs_pdu->srs_parameters_v4.report_type[0] = 1; + srs_pdu->srs_parameters_v4.iq_representation = 1; + srs_pdu->srs_parameters_v4.prg_size = 1; + srs_pdu->srs_parameters_v4.num_total_ue_antennas = 1 << srs_pdu->num_ant_ports; + srs_pdu->beamforming.num_prgs = m_SRS[srs_pdu->config_index]; + srs_pdu->beamforming.prg_size = 1; + } + + /// UE UL PDUs + + UE->ul_harq_processes[harq_pid].round = round; + UE_proc.nr_slot_tx = slot; + UE_proc.frame_tx = frame; + UE_proc.gNB_id = 0; + // prepare ULSCH/PUSCH reception pushNotifiedFIFO(&gNB->L1_tx_free, msgL1Tx); // to unblock the process in the beginning nr_schedule_response(Sched_INFO); @@ -1186,57 +1246,71 @@ int main(int argc, char **argv) // Config UL TX PDU tx_req.slot = slot; tx_req.sfn = frame; - // tx_req->tx_config // TbD - tx_req.number_of_pdus = 1; + tx_req.number_of_pdus = 1; //do_SRS == 1 ? 2 : 1; + tx_req.tx_request_body[0].pdu_length = TBS / 8; tx_req.tx_request_body[0].pdu_index = 0; tx_req.tx_request_body[0].pdu = &ulsch_input_buffer[0]; ul_config.slot = slot; - ul_config.number_pdus = 1; - ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; - ul_config.ul_config_list[0].pusch_config_pdu.rnti = n_rnti; - ul_config.ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; - ul_config.ul_config_list[0].pusch_config_pdu.qam_mod_order = mod_order; - ul_config.ul_config_list[0].pusch_config_pdu.rb_size = nb_rb; - ul_config.ul_config_list[0].pusch_config_pdu.rb_start = start_rb; - ul_config.ul_config_list[0].pusch_config_pdu.nr_of_symbols = nb_symb_sch; - ul_config.ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol; - ul_config.ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = l_prime_mask; - ul_config.ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; - ul_config.ul_config_list[0].pusch_config_pdu.mcs_index = Imcs; - ul_config.ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; - ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; - ul_config.ul_config_list[0].pusch_config_pdu.nrOfLayers = precod_nbr_layers; - ul_config.ul_config_list[0].pusch_config_pdu.dmrs_ports = ((1 << precod_nbr_layers) - 1); - ul_config.ul_config_list[0].pusch_config_pdu.absolute_delta_PUSCH = 0; - ul_config.ul_config_list[0].pusch_config_pdu.target_code_rate = code_rate; - ul_config.ul_config_list[0].pusch_config_pdu.tbslbrm = tbslbrm; - - ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS / 8; - ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = trial & 0x1; - ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index; - ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_pid; - - ul_config.ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; - ul_config.ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; - ul_config.ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = (nfapi_nr_ue_ptrs_ports_t *)malloc(2 * sizeof(nfapi_nr_ue_ptrs_ports_t)); - ul_config.ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; - - ul_config.ul_config_list[0].pusch_config_pdu.transform_precoding = transform_precoding; + ul_config.number_pdus = do_SRS == 1 ? 2 : 1; + fapi_nr_ul_config_request_pdu_t *ul_config0 = &ul_config.ul_config_list[0]; + ul_config0->pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config0->pusch_config_pdu; + pusch_config_pdu->rnti = n_rnti; + pusch_config_pdu->pdu_bit_map = pdu_bit_map; + pusch_config_pdu->qam_mod_order = mod_order; + pusch_config_pdu->rb_size = nb_rb; + pusch_config_pdu->rb_start = start_rb; + pusch_config_pdu->nr_of_symbols = nb_symb_sch; + pusch_config_pdu->start_symbol_index = start_symbol; + pusch_config_pdu->ul_dmrs_symb_pos = l_prime_mask; + pusch_config_pdu->dmrs_config_type = dmrs_config_type; + pusch_config_pdu->mcs_index = Imcs; + pusch_config_pdu->mcs_table = mcs_table; + pusch_config_pdu->num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; + pusch_config_pdu->nrOfLayers = precod_nbr_layers; + pusch_config_pdu->dmrs_ports = ((1 << precod_nbr_layers) - 1); + pusch_config_pdu->absolute_delta_PUSCH = 0; + pusch_config_pdu->target_code_rate = code_rate; + pusch_config_pdu->tbslbrm = tbslbrm; + pusch_config_pdu->pusch_data.tb_size = TBS / 8; + pusch_config_pdu->pusch_data.new_data_indicator = trial & 0x1; + pusch_config_pdu->pusch_data.rv_index = rv_index; + pusch_config_pdu->pusch_data.harq_process_id = harq_pid; + pusch_config_pdu->pusch_ptrs.ptrs_time_density = ptrs_time_density; + pusch_config_pdu->pusch_ptrs.ptrs_freq_density = ptrs_freq_density; + pusch_config_pdu->pusch_ptrs.ptrs_ports_list = (nfapi_nr_ue_ptrs_ports_t *)malloc(2 * sizeof(nfapi_nr_ue_ptrs_ports_t)); + pusch_config_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; + pusch_config_pdu->transform_precoding = transform_precoding; // if transform precoding is enabled if (transform_precoding == transformPrecoder_enabled) { - ul_config.ul_config_list[0].pusch_config_pdu.dfts_ofdm.low_papr_group_number = *scc->physCellId % 30; // U as defined in 38.211 section 6.4.1.1.1.2 - ul_config.ul_config_list[0].pusch_config_pdu.dfts_ofdm.low_papr_sequence_number = 0; // V as defined in 38.211 section 6.4.1.1.1.2 - // ul_config.ul_config_list[0].pusch_config_pdu.pdu_bit_map |= PUSCH_PDU_BITMAP_DFTS_OFDM; - ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; + pusch_config_pdu->dfts_ofdm.low_papr_group_number = *scc->physCellId % 30; // U as defined in 38.211 section 6.4.1.1.1.2 + pusch_config_pdu->dfts_ofdm.low_papr_sequence_number = 0; // V as defined in 38.211 section 6.4.1.1.1.2 + // pusch_config_pdu->pdu_bit_map |= PUSCH_PDU_BITMAP_DFTS_OFDM; + pusch_config_pdu->num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; } - // nr_fill_ulsch(gNB,frame,slot,pusch_pdu); // Not needed as its its already filled as apart of "nr_schedule_response(Sched_INFO);" + if (do_SRS == 1) { + fapi_nr_ul_config_request_pdu_t *ul_config1 = &ul_config.ul_config_list[1]; + ul_config1->pdu_type = FAPI_NR_UL_CONFIG_TYPE_SRS; + fapi_nr_ul_config_srs_pdu *srs_config_pdu = &ul_config1->srs_config_pdu; + memset(srs_config_pdu, 0, sizeof(fapi_nr_ul_config_srs_pdu)); + srs_config_pdu->rnti = n_rnti; + srs_config_pdu->bwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275); + srs_config_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275); + srs_config_pdu->subcarrier_spacing = frame_parms->subcarrier_spacing; + srs_config_pdu->num_ant_ports = n_tx == 4 ? 2 : n_tx == 2 ? 1 : 0; + srs_config_pdu->config_index = rrc_get_max_nr_csrs(srs_config_pdu->bwp_size, srs_config_pdu->bandwidth_index); + srs_config_pdu->sequence_id = 40; + srs_config_pdu->resource_type = NR_SRS_Resource__resourceType_PR_periodic; + srs_config_pdu->t_srs = 1; + } for (int i = 0; i < (TBS / 8); i++) UE->ul_harq_processes[harq_pid].a[i] = i & 0xff; + if (input_fd == NULL) { // set FAPI parameters for UE, put them in the scheduled response and call nr_ue_scheduled_response(&scheduled_response); @@ -1280,7 +1354,6 @@ int main(int argc, char **argv) // Justification of division by precod_nbr_layers: // When the channel is the identity matrix, the results in terms of SNR should be almost equal for 2x2 and 4x4. sigma_dB = 10 * log10((double)txlev_sum / precod_nbr_layers * ((double)frame_parms->ofdm_symbol_size / (12 * nb_rb))) - SNR; - ; sigma = pow(10, sigma_dB / 10); if (n_trials == 1) @@ -1310,6 +1383,7 @@ int main(int argc, char **argv) //---------------------------------------------------------- gNB->UL_INFO.rx_ind.number_of_pdus = 0; gNB->UL_INFO.crc_ind.number_crcs = 0; + gNB->UL_INFO.srs_ind.number_of_pdus = 0; for(uint8_t symbol = 0; symbol < (gNB->frame_parms.Ncp == EXTENDED ? 12 : 14); symbol++) { for (int aa = 0; aa < gNB->frame_parms.nb_antennas_rx; aa++) @@ -1606,6 +1680,14 @@ int main(int argc, char **argv) //printStatIndent2(&gNB->ulsch_deinterleaving_stats,"ULSCH deinterleaving"); //printStatIndent2(&gNB->ulsch_rate_unmatching_stats,"ULSCH rate matching rx"); //printStatIndent2(&gNB->ulsch_ldpc_decoding_stats,"ULSCH ldpc decoding"); + printStatIndent(&gNB->rx_srs_stats,"RX SRS time"); + printStatIndent2(&gNB->generate_srs_stats,"Generate SRS sequence time"); + printStatIndent2(&gNB->get_srs_signal_stats,"Get SRS signal time"); + printStatIndent2(&gNB->srs_channel_estimation_stats,"SRS channel estimation time"); + printStatIndent2(&gNB->srs_timing_advance_stats,"SRS timing advance estimation time"); + printStatIndent2(&gNB->srs_report_tlv_stats,"SRS report TLV build time"); + printStatIndent3(&gNB->srs_beam_report_stats,"SRS beam report build time"); + printStatIndent3(&gNB->srs_iq_matrix_stats,"SRS IQ matrix build time"); printf("\n"); } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 902bb2aec8..077dfc4568 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1014,8 +1014,8 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo srs_config_pdu->rnti = mac->crnti; srs_config_pdu->handle = 0; - srs_config_pdu->bwp_size = NRRIV2BW(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; - srs_config_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; + srs_config_pdu->bwp_size = NRRIV2BW(ubwp.locationAndBandwidth, MAX_BWP_SIZE); + srs_config_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp.locationAndBandwidth, MAX_BWP_SIZE); srs_config_pdu->subcarrier_spacing = ubwp.subcarrierSpacing; srs_config_pdu->cyclic_prefix = 0; srs_config_pdu->num_ant_ports = srs_resource->nrofSRS_Ports; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 0d25e160fa..f497f6ca70 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -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,34 +1178,35 @@ 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_beamforming_report; - unpack_nr_srs_beamforming_report(srs_ind->report_tlv->value, - srs_ind->report_tlv->length, - &nr_srs_beamforming_report, + nfapi_nr_srs_beamforming_report_t nr_srs_bf_report; + unpack_nr_srs_beamforming_report(report_tlv->value, + report_tlv->length, + &nr_srs_bf_report, sizeof(nfapi_nr_srs_beamforming_report_t)); - if (nr_srs_beamforming_report.wide_band_snr == 0xFF) { + if (nr_srs_bf_report.wide_band_snr == 0xFF) { LOG_W(NR_MAC, "Invalid wide_band_snr for RNTI %04x\n", srs_ind->rnti); return; } - int wide_band_snr_dB = (nr_srs_beamforming_report.wide_band_snr >> 1) - 64; + int wide_band_snr_dB = (nr_srs_bf_report.wide_band_snr >> 1) - 64; #ifdef SRS_IND_DEBUG - LOG_I(NR_MAC, "nr_srs_beamforming_report.prg_size = %i\n", nr_srs_beamforming_report.prg_size); - LOG_I(NR_MAC, "nr_srs_beamforming_report.num_symbols = %i\n", nr_srs_beamforming_report.num_symbols); - LOG_I(NR_MAC, "nr_srs_beamforming_report.wide_band_snr = %i (%i dB)\n", nr_srs_beamforming_report.wide_band_snr, wide_band_snr_dB); - LOG_I(NR_MAC, "nr_srs_beamforming_report.num_reported_symbols = %i\n", nr_srs_beamforming_report.num_reported_symbols); - LOG_I(NR_MAC, "nr_srs_beamforming_report.prgs[0].num_prgs = %i\n", nr_srs_beamforming_report.prgs[0].num_prgs); - for (int prg_idx = 0; prg_idx < nr_srs_beamforming_report.prgs[0].num_prgs; prg_idx++) { + LOG_I(NR_MAC, "nr_srs_bf_report.prg_size = %i\n", nr_srs_bf_report.prg_size); + LOG_I(NR_MAC, "nr_srs_bf_report.num_symbols = %i\n", nr_srs_bf_report.num_symbols); + LOG_I(NR_MAC, "nr_srs_bf_report.wide_band_snr = %i (%i dB)\n", nr_srs_bf_report.wide_band_snr, wide_band_snr_dB); + LOG_I(NR_MAC, "nr_srs_bf_report.num_reported_symbols = %i\n", nr_srs_bf_report.num_reported_symbols); + LOG_I(NR_MAC, "nr_srs_bf_report.prgs[0].num_prgs = %i\n", nr_srs_bf_report.prgs[0].num_prgs); + for (int prg_idx = 0; prg_idx < nr_srs_bf_report.prgs[0].num_prgs; prg_idx++) { LOG_I(NR_MAC, - "nr_srs_beamforming_report.prgs[0].prg_list[%3i].rb_snr = %i (%i dB)\n", + "nr_srs_bf_report.prgs[0].prg_list[%3i].rb_snr = %i (%i dB)\n", prg_idx, - nr_srs_beamforming_report.prgs[0].prg_list[prg_idx].rb_snr, - (nr_srs_beamforming_report.prgs[0].prg_list[prg_idx].rb_snr >> 1) - 64); + nr_srs_bf_report.prgs[0].prg_list[prg_idx].rb_snr, + (nr_srs_bf_report.prgs[0].prg_list[prg_idx].rb_snr >> 1) - 64); } #endif @@ -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_beamforming_report.prg_size * nr_srs_beamforming_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_beamforming_report.prgs[0].prg_list[rb / nr_srs_beamforming_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 } @@ -1228,31 +1229,31 @@ 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_normalized_channel_iq_matrix; - unpack_nr_srs_normalized_channel_iq_matrix(srs_ind->report_tlv->value, - srs_ind->report_tlv->length, - &nr_srs_normalized_channel_iq_matrix, + nfapi_nr_srs_normalized_channel_iq_matrix_t nr_srs_channel_iq_matrix; + 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)); #ifdef SRS_IND_DEBUG - LOG_I(NR_MAC, "nr_srs_normalized_channel_iq_matrix.normalized_iq_representation = %i\n", nr_srs_normalized_channel_iq_matrix.normalized_iq_representation); - LOG_I(NR_MAC, "nr_srs_normalized_channel_iq_matrix.num_gnb_antenna_elements = %i\n", nr_srs_normalized_channel_iq_matrix.num_gnb_antenna_elements); - LOG_I(NR_MAC, "nr_srs_normalized_channel_iq_matrix.num_ue_srs_ports = %i\n", nr_srs_normalized_channel_iq_matrix.num_ue_srs_ports); - LOG_I(NR_MAC, "nr_srs_normalized_channel_iq_matrix.prg_size = %i\n", nr_srs_normalized_channel_iq_matrix.prg_size); - LOG_I(NR_MAC, "nr_srs_normalized_channel_iq_matrix.num_prgs = %i\n", nr_srs_normalized_channel_iq_matrix.num_prgs); - c16_t *channel_matrix16 = (c16_t *)nr_srs_normalized_channel_iq_matrix.channel_matrix; - c8_t *channel_matrix8 = (c8_t *)nr_srs_normalized_channel_iq_matrix.channel_matrix; - for (int uI = 0; uI < nr_srs_normalized_channel_iq_matrix.num_ue_srs_ports; uI++) { - for (int gI = 0; gI < nr_srs_normalized_channel_iq_matrix.num_gnb_antenna_elements; gI++) { - for (int pI = 0; pI < nr_srs_normalized_channel_iq_matrix.num_prgs; pI++) { - uint16_t index = uI * nr_srs_normalized_channel_iq_matrix.num_gnb_antenna_elements * nr_srs_normalized_channel_iq_matrix.num_prgs + gI * nr_srs_normalized_channel_iq_matrix.num_prgs + pI; + LOG_I(NR_MAC, "nr_srs_channel_iq_matrix.normalized_iq_representation = %i\n", nr_srs_channel_iq_matrix.normalized_iq_representation); + LOG_I(NR_MAC, "nr_srs_channel_iq_matrix.num_gnb_antenna_elements = %i\n", nr_srs_channel_iq_matrix.num_gnb_antenna_elements); + LOG_I(NR_MAC, "nr_srs_channel_iq_matrix.num_ue_srs_ports = %i\n", nr_srs_channel_iq_matrix.num_ue_srs_ports); + LOG_I(NR_MAC, "nr_srs_channel_iq_matrix.prg_size = %i\n", nr_srs_channel_iq_matrix.prg_size); + LOG_I(NR_MAC, "nr_srs_channel_iq_matrix.num_prgs = %i\n", nr_srs_channel_iq_matrix.num_prgs); + c16_t *channel_matrix16 = (c16_t *)nr_srs_channel_iq_matrix.channel_matrix; + c8_t *channel_matrix8 = (c8_t *)nr_srs_channel_iq_matrix.channel_matrix; + for (int uI = 0; uI < nr_srs_channel_iq_matrix.num_ue_srs_ports; uI++) { + for (int gI = 0; gI < nr_srs_channel_iq_matrix.num_gnb_antenna_elements; gI++) { + for (int pI = 0; pI < nr_srs_channel_iq_matrix.num_prgs; pI++) { + uint16_t index = uI * nr_srs_channel_iq_matrix.num_gnb_antenna_elements * nr_srs_channel_iq_matrix.num_prgs + gI * nr_srs_channel_iq_matrix.num_prgs + pI; LOG_I(NR_MAC, "(uI %i, gI %i, pI %i) channel_matrix --> real %i, imag %i\n", uI, gI, pI, - nr_srs_normalized_channel_iq_matrix.normalized_iq_representation == 0 ? channel_matrix8[index].r : channel_matrix16[index].r, - nr_srs_normalized_channel_iq_matrix.normalized_iq_representation == 0 ? channel_matrix8[index].i : channel_matrix16[index].i); + nr_srs_channel_iq_matrix.normalized_iq_representation == 0 ? channel_matrix8[index].r : channel_matrix16[index].r, + nr_srs_channel_iq_matrix.normalized_iq_representation == 0 ? channel_matrix8[index].i : channel_matrix16[index].i); } } } @@ -1262,16 +1263,16 @@ void handle_nr_srs_measurements(const module_id_t module_id, NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; sched_ctrl->srs_feedback.sri = NR_SRS_SRI_0; - nr_srs_ri_computation(&nr_srs_normalized_channel_iq_matrix, current_BWP, &sched_ctrl->srs_feedback.ul_ri); + nr_srs_ri_computation(&nr_srs_channel_iq_matrix, current_BWP, &sched_ctrl->srs_feedback.ul_ri); sched_ctrl->srs_feedback.tpmi = nr_srs_tpmi_estimation(current_BWP->pusch_Config, current_BWP->transform_precoding, - nr_srs_normalized_channel_iq_matrix.channel_matrix, - nr_srs_normalized_channel_iq_matrix.normalized_iq_representation, - nr_srs_normalized_channel_iq_matrix.num_gnb_antenna_elements, - nr_srs_normalized_channel_iq_matrix.num_ue_srs_ports, - nr_srs_normalized_channel_iq_matrix.prg_size, - nr_srs_normalized_channel_iq_matrix.num_prgs, + nr_srs_channel_iq_matrix.channel_matrix, + nr_srs_channel_iq_matrix.normalized_iq_representation, + nr_srs_channel_iq_matrix.num_gnb_antenna_elements, + nr_srs_channel_iq_matrix.num_ue_srs_ports, + nr_srs_channel_iq_matrix.prg_size, + nr_srs_channel_iq_matrix.num_prgs, sched_ctrl->srs_feedback.ul_ri); sprintf(stats->srs_stats, "UL-RI %d, TPMI %d", sched_ctrl->srs_feedback.ul_ri + 1, sched_ctrl->srs_feedback.tpmi); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 2fa395b7a7..a1170c2660 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -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, diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index a0a7cf5d11..cd30c1bfb7 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -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; diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 7476286d5f..e5c1d4bd2b 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -375,7 +375,7 @@ void config_csiim(int do_csirs, int dl_antenna_ports, int curr_bwp, } // TODO: Implement to b_SRS = 1 and b_SRS = 2 -long rrc_get_max_nr_csrs(const uint8_t max_rbs, const long b_SRS) { +long rrc_get_max_nr_csrs(const int max_rbs, const long b_SRS) { if(b_SRS>0) { LOG_E(NR_RRC,"rrc_get_max_nr_csrs(): Not implemented yet for b_SRS>0\n");