ue,lte: update rx_gain_offset more frequently. Avoid calling UHD driver when getting rx_gain

This commit is contained in:
Ismael Gomez 2021-10-28 15:35:51 +02:00
parent 120ad5c72f
commit 2d31e11144
3 changed files with 13 additions and 13 deletions

View File

@ -141,6 +141,7 @@ struct rf_uhd_handler_t {
uint32_t nof_tx_channels = 0;
std::array<double, SRSRAN_MAX_CHANNELS> tx_freq = {};
std::array<double, SRSRAN_MAX_CHANNELS> rx_freq = {};
double cur_rx_gain_ch0 = 0;
std::mutex tx_gain_mutex;
std::array<std::pair<double, double>, SRSRAN_MAX_CHANNELS> tx_gain_db = {};
@ -1102,6 +1103,9 @@ int rf_uhd_set_rx_gain_ch(void* h, uint32_t ch, double gain)
if (handler->uhd->set_rx_gain(ch, gain) != UHD_ERROR_NONE) {
return SRSRAN_ERROR;
}
if (ch == 0) {
handler->cur_rx_gain_ch0 = gain;
}
return SRSRAN_SUCCESS;
}
@ -1146,13 +1150,7 @@ int rf_uhd_set_tx_gain_ch(void* h, uint32_t ch, double gain)
double rf_uhd_get_rx_gain(void* h)
{
rf_uhd_handler_t* handler = (rf_uhd_handler_t*)h;
double gain = 0.0;
if (handler->uhd->get_rx_gain(gain) != UHD_ERROR_NONE) {
return SRSRAN_ERROR;
}
return gain;
return handler->cur_rx_gain_ch0;
}
double rf_uhd_get_tx_gain(void* h)

View File

@ -324,7 +324,9 @@ private:
std::array<float, SRSRAN_MAX_CARRIERS> avg_rsrp_neigh = {};
static constexpr uint32_t pcell_report_period = 20;
uint32_t rssi_read_cnt = 0;
static constexpr uint32_t update_rxgain_period = 10;
uint32_t update_rxgain_cnt = 0;
rsrp_insync_itf* insync_itf = nullptr;

View File

@ -673,9 +673,9 @@ void phy_common::update_measurements(uint32_t cc_idx,
return;
}
// Only worker 0 reads the RSSI sensor
// Only worker 0 updates RX gain offset every 10 ms
if (rssi_power_buffer) {
if (!rssi_read_cnt) {
if (!update_rxgain_cnt) {
// Average RSSI over all symbols in antenna port 0 (make sure SF length is non-zero)
float rssi_dbm = SRSRAN_SF_LEN_PRB(cell.nof_prb) > 0
? (srsran_convert_power_to_dB(
@ -688,9 +688,9 @@ void phy_common::update_measurements(uint32_t cc_idx,
rx_gain_offset = get_radio()->get_rx_gain() + args->rx_gain_offset;
}
rssi_read_cnt++;
if (rssi_read_cnt >= 1000) {
rssi_read_cnt = 0;
update_rxgain_cnt++;
if (update_rxgain_cnt >= update_rxgain_period) {
update_rxgain_cnt = 0;
}
}