From e68c822505e2f01f7b97656cf2b4a8189864cf8f Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Tue, 4 May 2021 20:50:25 +0200 Subject: [PATCH] NR Added CSI measurement channel processing --- lib/include/srsran/phy/phch/csi.h | 14 +++++--- lib/include/srsran/phy/phch/csi_cfg.h | 47 ++++++++++++++++++++++++-- lib/include/srsran/phy/ue/ue_dl_nr.h | 8 +++++ lib/include/srsran/srsran.h | 1 + lib/src/phy/phch/csi.c | 48 +++++++++++++++++++++++++++ lib/src/phy/ue/ue_dl_nr.c | 12 +++++++ 6 files changed, 123 insertions(+), 7 deletions(-) diff --git a/lib/include/srsran/phy/phch/csi.h b/lib/include/srsran/phy/phch/csi.h index f8b024b0e..eaca13393 100644 --- a/lib/include/srsran/phy/phch/csi.h +++ b/lib/include/srsran/phy/phch/csi.h @@ -15,12 +15,18 @@ #include "uci_cfg_nr.h" +SRSRAN_API int +srsran_csi_new_nzp_csi_rs_measurement(const srsran_csi_hl_resource_cfg_t csi_resources[SRSRAN_CSI_MAX_NOF_RESOURCES], + srsran_csi_measurements_t measurements[SRSRAN_CSI_MAX_NOF_RESOURCES], + const srsran_csi_measurements_t* new_measure, + uint32_t nzp_csi_rs_id); + /** - * @brief Fills Uplink Control Information data with triggered reports for the given slot - * @param cfg CSI report configuration + * @brief Generates CSI report configuration and values from the higher layer configuration and a list of measurements + * @param cfg Higher layer report configuration * @param slot_idx Slot index within the radio frame - * @param measurements CSI measurements - * @param[out] uci_data Uplink Control Information data + * @param measurements Filtered CSI measurements + * @param[out] report_cfg Report configuration re * @return The number CSI reports for transmission if the provided data is valid, SRSRAN_ERROR code otherwise */ SRSRAN_API int srsran_csi_generate_reports(const srsran_csi_hl_cfg_t* cfg, diff --git a/lib/include/srsran/phy/phch/csi_cfg.h b/lib/include/srsran/phy/phch/csi_cfg.h index 40787c6be..73382e9b6 100644 --- a/lib/include/srsran/phy/phch/csi_cfg.h +++ b/lib/include/srsran/phy/phch/csi_cfg.h @@ -27,6 +27,22 @@ */ #define SRSRAN_CSI_MAX_NOF_RESOURCES 112 +/** + * @brief Maximum number of NZP-CSI-RS resources sets per config, defined in TS 38.331 + * maxNrofNZP-CSI-RS-ResourceSetsPerConfig + */ +#define SRSRAN_CSI_MAX_NOF_NZP_CSI_RS_RESOURCE_SETS_X_CONFIG 16 + +/** + * @brief Maximum number of CSI-SSB resources sets per config, defined in TS 38.331 maxNrofCSI-SSB-ResourceSetsPerConfig + */ +#define SRSRAN_CSI_MAX_NOF_CSI_SSB_RESOURCE_SETS_X_CONFIG 1 + +/** + * @brief Maximum number of CSI-SSB resources sets per config, defined in TS 38.331 maxNrofCSI-IM-ResourceSetsPerConfig + */ +#define SRSRAN_CSI_MAX_NOF_CSI_IM_RESOURCE_SETS_X_CONFIG 12 + /** * @brief CSI report types defined in TS 38.331 CSI-ReportConfig */ @@ -97,16 +113,41 @@ typedef struct SRSRAN_API { srsran_csi_report_freq_t freq_cfg; ///< Determine whether it is wideband or subband } srsran_csi_hl_report_cfg_t; +/** + * @brief CSI Resource configuration + */ +typedef struct SRSRAN_API { + enum { + SRSRAN_CSI_HL_RESOURCE_CFG_TYPE_NONE = 0, + SRSRAN_CSI_HL_RESOURCE_CFG_TYPE_NZP_CSI_RS_SSB, + SRSRAN_CSI_HL_RESOURCE_CFG_TYPE_IM + } type; + union { + struct { + uint32_t nzp_csi_rs_resource_set_id_list[SRSRAN_CSI_MAX_NOF_NZP_CSI_RS_RESOURCE_SETS_X_CONFIG]; + uint32_t nzp_csi_rs_resource_set_id_list_count; + uint32_t csi_ssb_rs_resource_set_id_list[SRSRAN_CSI_MAX_NOF_CSI_SSB_RESOURCE_SETS_X_CONFIG]; + uint32_t csi_ssb_rs_resource_set_id_list_count; + } nzp_csi_rs_ssb; + struct { + uint32_t resource_set_id_list[SRSRAN_CSI_MAX_NOF_CSI_IM_RESOURCE_SETS_X_CONFIG]; + uint32_t resource_set_id_list_count; + } csi_im; + }; +} srsran_csi_hl_resource_cfg_t; + /** * @brief General CSI configuration provided by higher layers */ typedef struct SRSRAN_API { - srsran_csi_hl_report_cfg_t reports[SRSRAN_CSI_MAX_NOF_REPORT]; ///< CSI report configuration - // ... add here physical CSI measurement sets + srsran_csi_hl_report_cfg_t reports[SRSRAN_CSI_MAX_NOF_REPORT]; ///< CSI report configuration indexed by + ///< reportConfigId + srsran_csi_hl_resource_cfg_t csi_resources[SRSRAN_CSI_MAX_NOF_RESOURCES]; ///< Configured CSI resource settings, + ///< indexed by csi-ResourceConfigId } srsran_csi_hl_cfg_t; /** - * @brief Generic measurement structure + * @brief Generic CSI measurement structure */ typedef struct SRSRAN_API { uint32_t cri; ///< CSI-RS Resource Indicator diff --git a/lib/include/srsran/phy/ue/ue_dl_nr.h b/lib/include/srsran/phy/ue/ue_dl_nr.h index fef512fad..380538d98 100644 --- a/lib/include/srsran/phy/ue/ue_dl_nr.h +++ b/lib/include/srsran/phy/ue/ue_dl_nr.h @@ -13,9 +13,11 @@ #ifndef SRSRAN_UE_DL_NR_H #define SRSRAN_UE_DL_NR_H +#include "srsran/phy/ch_estimation/csi_rs.h" #include "srsran/phy/ch_estimation/dmrs_pdcch.h" #include "srsran/phy/common/phy_common_nr.h" #include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/csi.h" #include "srsran/phy/phch/dci_nr.h" #include "srsran/phy/phch/pdcch_cfg_nr.h" #include "srsran/phy/phch/pdcch_nr.h" @@ -171,4 +173,10 @@ SRSRAN_API int srsran_ue_dl_nr_ack_insert_m(srsran_pdsch_ack_nr_t* ack_info, srs SRSRAN_API uint32_t srsran_ue_dl_nr_ack_info(const srsran_pdsch_ack_nr_t* ack_info, char* str, uint32_t str_len); +SRSRAN_API +int srsran_ue_dl_nr_csi_measure(const srsran_ue_dl_nr_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_csi_rs_nzp_set_t* csi_rs_nzp_set, + srsran_csi_measurements_t* measurement); + #endif // SRSRAN_UE_DL_NR_H diff --git a/lib/include/srsran/srsran.h b/lib/include/srsran/srsran.h index 6bcf7ceeb..b696984ce 100644 --- a/lib/include/srsran/srsran.h +++ b/lib/include/srsran/srsran.h @@ -39,6 +39,7 @@ extern "C" { #include "srsran/phy/ch_estimation/chest_dl.h" #include "srsran/phy/ch_estimation/chest_ul.h" +#include "srsran/phy/ch_estimation/csi_rs.h" #include "srsran/phy/ch_estimation/dmrs_pdcch.h" #include "srsran/phy/ch_estimation/dmrs_sch.h" #include "srsran/phy/ch_estimation/refsignal_dl.h" diff --git a/lib/src/phy/phch/csi.c b/lib/src/phy/phch/csi.c index f8f4599b1..9d87134a5 100644 --- a/lib/src/phy/phch/csi.c +++ b/lib/src/phy/phch/csi.c @@ -17,6 +17,8 @@ #define CSI_WIDEBAND_CSI_NOF_BITS 4 +#define CSI_DEFAULT_ALPHA 0.5f + /// Implements SNRI to CQI conversion uint32_t csi_snri_db_to_cqi(srsran_csi_cqi_table_t table, float snri_db) { @@ -142,6 +144,52 @@ csi_none_unpack(const srsran_csi_report_cfg_t* cfg, const uint8_t* o_csi1, srsra return cfg->K_csi_rs; } +int srsran_csi_new_nzp_csi_rs_measurement( + const srsran_csi_hl_resource_cfg_t csi_resources[SRSRAN_CSI_MAX_NOF_RESOURCES], + srsran_csi_measurements_t measurements[SRSRAN_CSI_MAX_NOF_RESOURCES], + const srsran_csi_measurements_t* new_measure, + uint32_t nzp_csi_rs_id) +{ + if (csi_resources == NULL || measurements == NULL || new_measure == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + + // Iterate all resources + for (uint32_t res_idx = 0; res_idx < SRSRAN_CSI_MAX_NOF_RESOURCES; res_idx++) { + // Skip resource is set to none + if (csi_resources[res_idx].type != SRSRAN_CSI_HL_RESOURCE_CFG_TYPE_NZP_CSI_RS_SSB) { + continue; + } + + // Look for the NZP-CSI reource set + bool present = false; + for (uint32_t i = 0; i < SRSRAN_CSI_MAX_NOF_NZP_CSI_RS_RESOURCE_SETS_X_CONFIG && !present; i++) { + if (csi_resources[res_idx].nzp_csi_rs_ssb.nzp_csi_rs_resource_set_id_list[i] == nzp_csi_rs_id) { + present = true; + } + } + + // Skip Resource if it does not contain the NZP-CSI-RS set + if (!present) { + continue; + } + + // Filter measurements + measurements[res_idx].wideband_rsrp_dBm = + SRSRAN_VEC_SAFE_EMA(new_measure->wideband_rsrp_dBm, measurements[res_idx].wideband_rsrp_dBm, CSI_DEFAULT_ALPHA); + measurements[res_idx].wideband_epre_dBm = + SRSRAN_VEC_SAFE_EMA(new_measure->wideband_epre_dBm, measurements[res_idx].wideband_epre_dBm, CSI_DEFAULT_ALPHA); + measurements[res_idx].wideband_snr_db = + SRSRAN_VEC_SAFE_EMA(new_measure->wideband_snr_db, measurements[res_idx].wideband_snr_db, CSI_DEFAULT_ALPHA); + + // Force rest + measurements[res_idx].cri = new_measure->cri; + measurements[res_idx].K_csi_rs = new_measure->K_csi_rs; + } + + return SRSRAN_SUCCESS; +} + int srsran_csi_generate_reports(const srsran_csi_hl_cfg_t* cfg, uint32_t slot_idx, const srsran_csi_measurements_t measurements[SRSRAN_CSI_MAX_NOF_RESOURCES], diff --git a/lib/src/phy/ue/ue_dl_nr.c b/lib/src/phy/ue/ue_dl_nr.c index cf45ea0fc..8c6105078 100644 --- a/lib/src/phy/ue/ue_dl_nr.c +++ b/lib/src/phy/ue/ue_dl_nr.c @@ -838,3 +838,15 @@ uint32_t srsran_ue_dl_nr_ack_info(const srsran_pdsch_ack_nr_t* ack_info, char* s return len; } + +int srsran_ue_dl_nr_csi_measure(const srsran_ue_dl_nr_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_csi_rs_nzp_set_t* csi_rs_nzp_set, + srsran_csi_measurements_t* measurement) +{ + if (q == NULL || slot_cfg == NULL || csi_rs_nzp_set == NULL || measurement == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + + return srsran_csi_rs_nzp_measure_channel(&q->carrier, slot_cfg, csi_rs_nzp_set, q->sf_symbols[0], measurement); +} \ No newline at end of file