diff --git a/srslte/include/srslte/phch/cqi.h b/srslte/include/srslte/phch/cqi.h index 947c528a1..68ed8ca2a 100644 --- a/srslte/include/srslte/phch/cqi.h +++ b/srslte/include/srslte/phch/cqi.h @@ -122,6 +122,10 @@ SRSLTE_API int srslte_cqi_format2_subband_pack(srslte_cqi_format2_subband_t *msg SRSLTE_API bool srslte_cqi_send(uint32_t I_cqi_pmi, uint32_t tti); -SRSLTE_API uint8_t srslte_cqi_from_snr(float snr); +SRSLTE_API uint8_t srslte_cqi_from_snr(float snr); + +SRSLTE_API int srslte_cqi_hl_get_subband_size(int num_prbs); + +SRSLTE_API int srslte_cqi_hl_get_no_subbands(int num_prbs); #endif // CQI_ diff --git a/srslte/lib/phch/cqi.c b/srslte/lib/phch/cqi.c index 4ebaa8920..a19060961 100644 --- a/srslte/lib/phch/cqi.c +++ b/srslte/lib/phch/cqi.c @@ -157,4 +157,29 @@ uint8_t srslte_cqi_from_snr(float snr) return 0; } +/* Returns the subband size for higher layer-configured subband feedback, + * i.e., the number of RBs per subband as a function of the cell bandwidth + * (Table 7.2.1-3 in TS 36.213) + */ +int srslte_cqi_hl_get_subband_size(int nof_prb) +{ + if (nof_prb < 7) { + return 0; + } else if (nof_prb <= 26) { + return 4; + } else if (nof_prb <= 63) { + return 6; + } else if (nof_prb <= 110) { + return 8; + } else { + return -1; + } +} +/* Returns the number of subbands to be reported in CQI measurements as + * defined in clause 7.2 in TS 36.213, i.e., the N parameter + */ +int srslte_cqi_hl_get_no_subbands(int nof_prb) +{ + return (int)ceil(nof_prb/(float)srslte_cqi_hl_get_subband_size(nof_prb)); +}