From 7ba5099bee74a8013a49e5b2d87abfc7efa222ab Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Mon, 20 Sep 2021 10:53:09 +0200 Subject: [PATCH] Implement CSI-RS resource mapping validation --- .../srsran/phy/ch_estimation/csi_rs_cfg.h | 2 ++ lib/src/asn1/rrc_nr_utils.cc | 17 ++++++++++++++ lib/src/phy/ch_estimation/csi_rs.c | 23 +++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/lib/include/srsran/phy/ch_estimation/csi_rs_cfg.h b/lib/include/srsran/phy/ch_estimation/csi_rs_cfg.h index 3da47d268..1be7edf90 100644 --- a/lib/include/srsran/phy/ch_estimation/csi_rs_cfg.h +++ b/lib/include/srsran/phy/ch_estimation/csi_rs_cfg.h @@ -128,4 +128,6 @@ typedef struct SRSRAN_API { uint32_t count; ///< Number of resources in the set } srsran_csi_rs_zp_set_t; +SRSRAN_API bool srsran_csi_rs_resource_mapping_is_valid(const srsran_csi_rs_resource_mapping_t *res); + #endif // SRSRAN_CSI_RS_CFG_H diff --git a/lib/src/asn1/rrc_nr_utils.cc b/lib/src/asn1/rrc_nr_utils.cc index 32c386a74..679b38067 100644 --- a/lib/src/asn1/rrc_nr_utils.cc +++ b/lib/src/asn1/rrc_nr_utils.cc @@ -1070,6 +1070,15 @@ bool make_phy_zp_csi_rs_resource(const asn1::rrc_nr::zp_csi_rs_res_s& zp_csi_rs_ } zp_csi_rs_resource.resource_mapping.freq_band.nof_rb = zp_csi_rs_res.res_map.freq_band.nrof_rbs; zp_csi_rs_resource.resource_mapping.freq_band.start_rb = zp_csi_rs_res.res_map.freq_band.start_rb; + + // Validate CSI-RS resource mapping + if (not srsran_csi_rs_resource_mapping_is_valid(&zp_csi_rs_resource.resource_mapping)) { + asn1::json_writer json_writer; + zp_csi_rs_res.res_map.to_json(json_writer); + asn1::log_error("Resource mapping is invalid or not implemented: %s", json_writer.to_string()); + return false; + } + if (zp_csi_rs_res.periodicity_and_offset_present) { switch (zp_csi_rs_res.periodicity_and_offset.type()) { case csi_res_periodicity_and_offset_c::types_opts::options::slots4: @@ -1228,6 +1237,14 @@ bool make_phy_nzp_csi_rs_resource(const asn1::rrc_nr::nzp_csi_rs_res_s& asn1_nzp csi_rs_nzp_resource.resource_mapping.freq_band.nof_rb = asn1_nzp_csi_rs_res.res_map.freq_band.nrof_rbs; csi_rs_nzp_resource.resource_mapping.freq_band.start_rb = asn1_nzp_csi_rs_res.res_map.freq_band.start_rb; + // Validate CSI-RS resource mapping + if (not srsran_csi_rs_resource_mapping_is_valid(&csi_rs_nzp_resource.resource_mapping)) { + asn1::json_writer json_writer; + asn1_nzp_csi_rs_res.res_map.to_json(json_writer); + asn1::log_error("Resource mapping is invalid or not implemented: %s", json_writer.to_string()); + return false; + } + csi_rs_nzp_resource.power_control_offset = asn1_nzp_csi_rs_res.pwr_ctrl_offset; if (asn1_nzp_csi_rs_res.pwr_ctrl_offset_ss_present) { csi_rs_nzp_resource.power_control_offset_ss = asn1_nzp_csi_rs_res.pwr_ctrl_offset_ss.to_number(); diff --git a/lib/src/phy/ch_estimation/csi_rs.c b/lib/src/phy/ch_estimation/csi_rs.c index cfe490705..6c7c3920b 100644 --- a/lib/src/phy/ch_estimation/csi_rs.c +++ b/lib/src/phy/ch_estimation/csi_rs.c @@ -232,6 +232,29 @@ static int csi_rs_nof_cdm_groups(const srsran_csi_rs_resource_mapping_t* resourc return SRSRAN_ERROR; } +bool srsran_csi_rs_resource_mapping_is_valid(const srsran_csi_rs_resource_mapping_t* res) +{ + if (res == NULL) { + return false; + } + + if (csi_rs_nof_cdm_groups(res) < 1) { + return false; + } + + uint32_t l_list[CSI_RS_MAX_SYMBOLS_SLOT] = {}; + if (csi_rs_location_get_l_list(res, 0, l_list) < SRSRAN_SUCCESS) { + return false; + } + + uint32_t k_list[CSI_RS_MAX_SUBC_PRB] = {}; + if (csi_rs_location_get_k_list(res, 0, k_list) < SRSRAN_SUCCESS) { + return false; + } + + return true; +} + uint32_t csi_rs_count(srsran_csi_rs_density_t density, uint32_t nprb) { switch (density) {