From e717aec2f733ef32608734a771b80d453654f9a0 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Wed, 13 Nov 2019 13:17:20 +0100 Subject: Move and rename gsm_lchan.ms_power field Make it clear that it contains the maximum MS power level (TS 05.05) and not the one to be used. The one aimed at is in ms_power_ctrl.current. Since it's used in related code, move it inside the ms_power_ctrl struct too. Related: OS#1851 Change-Id: Ib264ec7dac87355cef6415461ed74bd8e9c8ca52 --- include/osmo-bts/gsm_data_shared.h | 6 +++--- src/common/power_control.c | 4 ++-- src/common/rsl.c | 23 +++++++++++------------ src/common/vty.c | 2 +- src/osmo-bts-trx/loops.c | 4 ++-- src/osmo-bts-virtual/l1_if.c | 2 +- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/include/osmo-bts/gsm_data_shared.h b/include/osmo-bts/gsm_data_shared.h index 50613103..8a52fe9f 100644 --- a/include/osmo-bts/gsm_data_shared.h +++ b/include/osmo-bts/gsm_data_shared.h @@ -199,9 +199,6 @@ struct gsm_lchan { /* State */ enum gsm_lchan_state state; const char *broken_reason; - /* Power levels for MS and BTS */ - uint8_t bs_power; - uint8_t ms_power; /* Encryption information */ struct { uint8_t alg_id; @@ -323,8 +320,11 @@ struct gsm_lchan { /* power handling */ struct { uint8_t current; + uint8_t max; bool fixed; } ms_power_ctrl; + /* Power levels for BTS */ + uint8_t bs_power; struct msgb *pending_rel_ind_msg; diff --git a/src/common/power_control.c b/src/common/power_control.c index f467cd53..38a7fb77 100644 --- a/src/common/power_control.c +++ b/src/common/power_control.c @@ -83,8 +83,8 @@ int lchan_ms_pwr_ctrl(struct gsm_lchan *lchan, /* Don't ask for smaller ms power level than the one set * by BSC upon RSL CHAN ACT */ - if (new_pwr < lchan->ms_power) - new_pwr = lchan->ms_power; + if (new_pwr < lchan->ms_power_ctrl.max) + new_pwr = lchan->ms_power_ctrl.max; if (lchan->ms_power_ctrl.current != new_pwr) { lchan->ms_power_ctrl.current = new_pwr; diff --git a/src/common/rsl.c b/src/common/rsl.c index f88d2d70..09a9217d 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -1002,7 +1002,6 @@ static void clear_lchan_for_pdch_activ(struct gsm_lchan *lchan) memset(&lchan->encr, 0, sizeof(lchan->encr)); memset(&lchan->ho, 0, sizeof(lchan->ho)); lchan->bs_power = 0; - lchan->ms_power = 0; memset(&lchan->ms_power_ctrl, 0, sizeof(lchan->ms_power_ctrl)); lchan->rqd_ta = 0; copy_sacch_si_to_lchan(lchan); @@ -1099,8 +1098,8 @@ static int rsl_rx_chan_activ(struct msgb *msg) gsm_lchans_name(lchan->state)); /* Initialize channel defaults */ - lchan->ms_power = ms_pwr_ctl_lvl(lchan->ts->trx->bts->band, 0); - lchan->ms_power_ctrl.current = lchan->ms_power; + lchan->ms_power_ctrl.max = ms_pwr_ctl_lvl(lchan->ts->trx->bts->band, 0); + lchan->ms_power_ctrl.current = lchan->ms_power_ctrl.max; lchan->ms_power_ctrl.fixed = false; rsl_tlv_parse(&tp, msgb_l3(msg), msgb_l3len(msg)); @@ -1151,8 +1150,8 @@ static int rsl_rx_chan_activ(struct msgb *msg) lchan->bs_power = *TLVP_VAL(&tp, RSL_IE_BS_POWER); /* 9.3.13 MS Power */ if (TLVP_PRES_LEN(&tp, RSL_IE_MS_POWER, 1)) { - lchan->ms_power = *TLVP_VAL(&tp, RSL_IE_MS_POWER); - lchan->ms_power_ctrl.current = lchan->ms_power; + lchan->ms_power_ctrl.max = *TLVP_VAL(&tp, RSL_IE_MS_POWER); + lchan->ms_power_ctrl.current = lchan->ms_power_ctrl.max; lchan->ms_power_ctrl.fixed = false; } /* 9.3.24 Timing Advance */ @@ -1633,7 +1632,7 @@ static int rsl_rx_ms_pwr_ctrl(struct msgb *msg) return rsl_tx_error_report(msg->trx, RSL_ERR_MAND_IE_ERROR, &dch->chan_nr, NULL, msg); pwr = *TLVP_VAL(&tp, RSL_IE_MS_POWER) & 0x1F; - lchan->ms_power = pwr; + lchan->ms_power_ctrl.max = pwr; LOGPLCHAN(lchan, DRSL, LOGL_INFO, "Rx MS POWER CONTROL %" PRIu8 "\n", pwr); @@ -1647,20 +1646,20 @@ static int rsl_rx_ms_pwr_ctrl(struct msgb *msg) lchan->ms_power_ctrl.fixed = true; } - /* Only set current to lchan->ms_power if actual value of current - in dBm > value in dBm from lchan->ms_power, or if fixed. */ + /* Only set current to max if actual value of current + in dBm > value in dBm from max, or if fixed. */ if (lchan->ms_power_ctrl.fixed) { - lchan->ms_power_ctrl.current = lchan->ms_power; + lchan->ms_power_ctrl.current = lchan->ms_power_ctrl.max; } else { - max_pwr = ms_pwr_dbm(bts->band, lchan->ms_power); + max_pwr = ms_pwr_dbm(bts->band, lchan->ms_power_ctrl.max); curr_pwr = ms_pwr_dbm(bts->band, lchan->ms_power_ctrl.current); if (max_pwr < 0 || curr_pwr < 0) { LOGPLCHAN(lchan, DRSL, LOGL_ERROR, "Unable to calculate power levels to dBm: %" PRIu8 " -> %d, %" PRIu8 " -> %d\n", - lchan->ms_power, max_pwr, + lchan->ms_power_ctrl.max, max_pwr, lchan->ms_power_ctrl.current, curr_pwr); } else if (curr_pwr > max_pwr) { - lchan->ms_power_ctrl.current = lchan->ms_power; + lchan->ms_power_ctrl.current = lchan->ms_power_ctrl.max; } } diff --git a/src/common/vty.c b/src/common/vty.c index fd9be40c..514d1202 100644 --- a/src/common/vty.c +++ b/src/common/vty.c @@ -1173,7 +1173,7 @@ static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan) vty_out(vty, " BS Power: %d dBm, MS Power: %u dBm%s", lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red - lchan->bs_power*2, - ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power), + ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power_ctrl.max), VTY_NEWLINE); vty_out(vty, " Channel Mode / Codec: %s%s", get_value_string(gsm48_cmode_names, lchan->tch_mode), diff --git a/src/osmo-bts-trx/loops.c b/src/osmo-bts-trx/loops.c index b2b163a1..4b723a01 100644 --- a/src/osmo-bts-trx/loops.c +++ b/src/osmo-bts-trx/loops.c @@ -62,11 +62,11 @@ static void ms_power_diff(struct gsm_lchan *lchan, int8_t diff) lchan->ms_power_ctrl.current, gsm_band_name(band)); return; } - bsc_max_dbm = ms_pwr_dbm(band, lchan->ms_power); + bsc_max_dbm = ms_pwr_dbm(band, lchan->ms_power_ctrl.max); if (bsc_max_dbm < 0) { LOGPLCHAN(lchan, DLOOP, LOGL_NOTICE, "Failed to calculate dBm for power ctl level %" PRIu8 " on band %s\n", - lchan->ms_power, gsm_band_name(band)); + lchan->ms_power_ctrl.max, gsm_band_name(band)); return; } diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c index 58f47814..ab2cb762 100644 --- a/src/osmo-bts-virtual/l1_if.c +++ b/src/osmo-bts-virtual/l1_if.c @@ -320,7 +320,7 @@ static int l1if_process_meas_res(struct gsm_bts_trx *trx, uint8_t tn, uint32_t f DEBUGPFN(DMEAS, fn, "RX L1 frame %s chan_nr=0x%02x MS pwr=%ddBm rssi=%.1f dBFS " "ber=%.2f%% (%d/%d bits) L1_ta=%d rqd_ta=%d toa=%.2f\n", - gsm_lchan_name(lchan), chan_nr, ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power), + gsm_lchan_name(lchan), chan_nr, ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power_ctrl.max), rssi, ber*100, n_errors, n_bits_total, lchan->meas.l1_info[1], lchan->rqd_ta, toa); l1if_fill_meas_res(&l1sap, chan_nr, lchan->rqd_ta + toa, ber, rssi, fn); -- cgit v1.2.3