Change in osmo-bts[master]: A-bis/RSL: refactor handling of BS Power IE (power reduction)

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Jun 16 08:32:42 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/18835 )

Change subject: A-bis/RSL: refactor handling of BS Power IE (power reduction)
......................................................................

A-bis/RSL: refactor handling of BS Power IE (power reduction)

According to 3GPP TS 08.58, section 9.3.4, BS Power IE indicates
the transmission power attenuation on a particular channel:

  +--------------+---------+-----------------+
  | Reserved (3) | FPC (1) | Power level (4) |
  +--------------+---------+-----------------+

so let's change handling of this IE as follows:

  - s/bs_power/bs_power_red/g, so it reflects 'reduction';
  - store power attenuation value in dB, not in 2 db steps;
  - get rid of ms_power_ctrl.bts_tx_pwr, it's always 0 anyway;
    - fix rsl_tx_meas_res(): use lchan->bs_power_red;
  - always check if FPC (Fast Power Control) flag is set;
    - we don't support it, so reject messages containing it;
    - fix rsl_rx_chan_activ(): properly apply the bitmask.

Change-Id: I16cc50dfca102030380a06e16c234d5f6698f38f
---
M include/osmo-bts/gsm_data_shared.h
M include/osmo-bts/tx_power.h
M src/common/rsl.c
M src/common/scheduler.c
M src/common/tx_power.c
M src/common/vty.c
M tests/tx_power/tx_power_test.c
7 files changed, 50 insertions(+), 43 deletions(-)

Approvals:
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Jenkins Builder: Verified
  fixeria: Verified



diff --git a/include/osmo-bts/gsm_data_shared.h b/include/osmo-bts/gsm_data_shared.h
index 7cfbfeb..bbc1bd4 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -193,8 +193,6 @@
 		uint8_t flags;
 		/* RSL measurement result number, 0 at lchan_act */
 		uint8_t res_nr;
-		/* current Tx power level of the BTS */
-		uint8_t bts_tx_pwr;
 		/* number of measurements stored in array below */
 		uint8_t num_ul_meas;
 		struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
@@ -267,8 +265,9 @@
 		uint8_t max;
 		bool fixed;
 	} ms_power_ctrl;
-	/* Power levels for BTS */
-	uint8_t bs_power;
+
+	/* BTS power reduction (in dB) */
+	uint8_t bs_power_red;
 
 	struct msgb *pending_rel_ind_msg;
 
diff --git a/include/osmo-bts/tx_power.h b/include/osmo-bts/tx_power.h
index 10129eb..8f33100 100644
--- a/include/osmo-bts/tx_power.h
+++ b/include/osmo-bts/tx_power.h
@@ -62,15 +62,15 @@
 
 int get_p_nominal_mdBm(struct gsm_bts_trx *trx);
 
-int get_p_target_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_ie);
+int get_p_target_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_red);
 int get_p_target_mdBm_lchan(struct gsm_lchan *lchan);
 
 int get_p_actual_mdBm(struct gsm_bts_trx *trx, int p_target_mdBm);
 
-int get_p_trxout_target_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_ie);
+int get_p_trxout_target_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_red);
 int get_p_trxout_target_mdBm_lchan(struct gsm_lchan *lchan);
 
-int get_p_trxout_actual_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_ie);
+int get_p_trxout_actual_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_red);
 int get_p_trxout_actual_mdBm_lchan(struct gsm_lchan *lchan);
 
 int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int bypass);
diff --git a/src/common/rsl.c b/src/common/rsl.c
index f057a89..b518245 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -60,6 +60,9 @@
 
 //#define FAKE_CIPH_MODE_COMPL
 
+/* Parse power attenuation (in dB) from BS Power IE (see 9.3.4) */
+#define BS_POWER2DB(bs_power) \
+	((bs_power & 0x0f) * 2)
 
 static int rsl_tx_error_report(struct gsm_bts_trx *trx, uint8_t cause, const uint8_t *chan_nr,
 				const uint8_t *link_id, const struct msgb *orig_msg);
@@ -1001,7 +1004,7 @@
 	lchan->tch_mode = 0;
 	memset(&lchan->encr, 0, sizeof(lchan->encr));
 	memset(&lchan->ho, 0, sizeof(lchan->ho));
-	lchan->bs_power = 0;
+	lchan->bs_power_red = 0;
 	memset(&lchan->ms_power_ctrl, 0, sizeof(lchan->ms_power_ctrl));
 	lchan->rqd_ta = 0;
 	copy_sacch_si_to_lchan(lchan);
@@ -1146,8 +1149,18 @@
 	}
 
 	/* 9.3.4 BS Power */
-	if (TLVP_PRES_LEN(&tp, RSL_IE_BS_POWER, 1))
-		lchan->bs_power = *TLVP_VAL(&tp, RSL_IE_BS_POWER);
+	if (TLVP_PRES_LEN(&tp, RSL_IE_BS_POWER, 1)) {
+		if (*TLVP_VAL(&tp, RSL_IE_BS_POWER) & (1 << 4)) {
+			LOGPLCHAN(lchan, DRSL, LOGL_NOTICE,
+				  "Fast Power Control is not supported\n");
+			return rsl_tx_chan_act_nack(lchan, RSL_ERR_SERV_OPT_UNIMPL);
+		}
+
+		lchan->bs_power_red = BS_POWER2DB(*TLVP_VAL(&tp, RSL_IE_BS_POWER));
+		LOGPLCHAN(lchan, DRSL, LOGL_DEBUG, "BS Power attenuation %u dB\n",
+			  lchan->bs_power_red);
+	}
+
 	/* 9.3.13 MS Power */
 	if (TLVP_PRES_LEN(&tp, RSL_IE_MS_POWER, 1)) {
 		lchan->ms_power_ctrl.max = *TLVP_VAL(&tp, RSL_IE_MS_POWER) & 0x1F;
@@ -1664,21 +1677,13 @@
 	return 0;
 }
 
-/* See TS 48.058 Section 9.3.4 */
-static int bs_power_attenuation_dB(uint8_t bs_power)
-{
-	/* the lower nibble contains the number of 2dB steps that the BS power is reduced compared
-	 * to its nominal transmit power */
-	return - ((bs_power & 0xF) *2);
-}
-
 /* 8.4.16 BS POWER CONTROL */
 static int rsl_rx_bs_pwr_ctrl(struct msgb *msg)
 {
 	struct abis_rsl_dchan_hdr *dch = msgb_l2(msg);
 	struct gsm_lchan *lchan = msg->lchan;
 	struct tlv_parsed tp;
-	uint8_t new_bs_power;
+	uint8_t old_bs_power_red;
 
 	rsl_tlv_parse(&tp, msgb_l3(msg), msgb_l3len(msg));
 
@@ -1686,12 +1691,16 @@
 	if (!TLVP_PRES_LEN(&tp, RSL_IE_BS_POWER, 1))
 		return rsl_tx_error_report(msg->trx, RSL_ERR_MAND_IE_ERROR, &dch->chan_nr, NULL, msg);
 
-	new_bs_power = *TLVP_VAL(&tp, RSL_IE_BS_POWER);
+	if (*TLVP_VAL(&tp, RSL_IE_BS_POWER) & (1 << 4)) {
+		LOGPLCHAN(lchan, DRSL, LOGL_NOTICE, "Fast Power Control is not supported\n");
+		return rsl_tx_error_report(msg->trx, RSL_ERR_SERV_OPT_UNIMPL, &dch->chan_nr, NULL, msg);
+	}
+
+	old_bs_power_red = lchan->bs_power_red;
+	lchan->bs_power_red = BS_POWER2DB(*TLVP_VAL(&tp, RSL_IE_BS_POWER));
 
 	LOGPLCHAN(lchan, DRSL, LOGL_INFO, "BS POWER CONTROL Attenuation %d -> %d dB\n",
-		  bs_power_attenuation_dB(lchan->bs_power), bs_power_attenuation_dB(new_bs_power));
-
-	lchan->bs_power = new_bs_power;
+		  old_bs_power_red, lchan->bs_power_red);
 
 	/* 9.3.31 MS Power Parameters (O) */
 	if (TLVP_PRESENT(&tp, RSL_IE_BS_POWER_PARAM)) {
@@ -2896,7 +2905,7 @@
 		msgb_tlv_put(msg, RSL_IE_UPLINK_MEAS, ie_len, meas_res);
 		lchan->meas.flags &= ~LC_UL_M_F_RES_VALID;
 	}
-	msgb_tv_put(msg, RSL_IE_BS_POWER, lchan->meas.bts_tx_pwr);
+	msgb_tv_put(msg, RSL_IE_BS_POWER, lchan->bs_power_red / 2);
 	if (lchan->meas.flags & LC_UL_M_F_L1_VALID) {
 		msgb_tv_fixed_put(msg, RSL_IE_L1_INFO, 2, lchan->meas.l1_info);
 		lchan->meas.flags &= ~LC_UL_M_F_L1_VALID;
diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index ac9085d..e55b3a4 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -1190,9 +1190,9 @@
 	if (func(l1t, chan, bid, br) != 0)
 		goto no_data;
 
-	/* BS Power reduction (2 dB steps) per logical channel */
+	/* BS Power reduction (in dB) per logical channel */
 	if (l1cs->lchan != NULL)
-		br->att = l1cs->lchan->bs_power * 2;
+		br->att = l1cs->lchan->bs_power_red;
 
 	/* encrypt */
 	if (br->burst_len && l1cs->dl_encr_algo) {
diff --git a/src/common/tx_power.c b/src/common/tx_power.c
index e418cec..db3121d 100644
--- a/src/common/tx_power.c
+++ b/src/common/tx_power.c
@@ -60,14 +60,14 @@
 /* calculate the target total output power required, reduced by both
  * OML and RSL, but ignoring the attenuation required for power ramping and
  * thermal management */
-int get_p_target_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_ie)
+int get_p_target_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_red)
 {
-	/* Pn subtracted by RSL BS Power IE (in 2 dB steps) */
-	return get_p_nominal_mdBm(trx) - to_mdB(bs_power_ie * 2);
+	/* Pn subtracted by RSL BS Power Recudtion (in 1 dB steps) */
+	return get_p_nominal_mdBm(trx) - to_mdB(bs_power_red);
 }
 int get_p_target_mdBm_lchan(struct gsm_lchan *lchan)
 {
-	return get_p_target_mdBm(lchan->ts->trx, lchan->bs_power);
+	return get_p_target_mdBm(lchan->ts->trx, lchan->bs_power_red);
 }
 
 /* calculate the actual total output power required, taking into account the
@@ -113,14 +113,14 @@
 
 /* calculate target TRX output power required, ignoring the
  * attenuations required for power ramping but not thermal management */
-int get_p_trxout_target_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_ie)
+int get_p_trxout_target_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_red)
 {
 	struct trx_power_params *tpp = &trx->power_params;
 	int p_target_mdBm, user_pa_drvlvl_mdBm, pa_drvlvl_mdBm;
 	unsigned int arfcn = trx->arfcn;
 
 	/* P_target subtracted by any bulk gain added by the user */
-	p_target_mdBm = get_p_target_mdBm(trx, bs_power_ie) - tpp->user_gain_mdB;
+	p_target_mdBm = get_p_target_mdBm(trx, bs_power_red) - tpp->user_gain_mdB;
 
 	/* determine input drive level required at input to user PA */
 	user_pa_drvlvl_mdBm = get_pa_drive_level_mdBm(&tpp->user_pa, p_target_mdBm, arfcn);
@@ -133,7 +133,7 @@
 }
 int get_p_trxout_target_mdBm_lchan(struct gsm_lchan *lchan)
 {
-	return get_p_trxout_target_mdBm(lchan->ts->trx, lchan->bs_power);
+	return get_p_trxout_target_mdBm(lchan->ts->trx, lchan->bs_power_red);
 }
 
 
diff --git a/src/common/vty.c b/src/common/vty.c
index 3dfd387..6a1fd9c 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -1182,8 +1182,7 @@
 		lchan->state == LCHAN_S_BROKEN ? lchan->broken_reason : "",
 		VTY_NEWLINE);
 	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,
+		lchan->ts->trx->nominal_power - (lchan->ts->trx->max_power_red + lchan->bs_power_red),
 		ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power_ctrl.max),
 		VTY_NEWLINE);
 	vty_out(vty, "  Channel Mode / Codec: %s%s",
diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c
index 9d38d83..aaa34ea 100644
--- a/tests/tx_power/tx_power_test.c
+++ b/tests/tx_power/tx_power_test.c
@@ -120,9 +120,9 @@
 	/* at max_power_red = 2, we expect 21dBm */
 	OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(21));
 	/* at 1 step (of 2dB), we expect full 23-2-2=19 dBm */
-	OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(19));
+	OSMO_ASSERT(get_p_target_mdBm(trx, 2) == to_mdB(19));
 	/* at 2 steps (= 4dB), we expect 23-2-4=17*/
-	OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17));
+	OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 4) == to_mdB(17));
 }
 
 static void test_sbts1020(struct gsm_bts_trx *trx)
@@ -138,9 +138,9 @@
 	/* at max_power_red = 2, we expect 31dBm */
 	OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(31));
 	/* at 1 step (of 2dB), we expect full 33-2-2=29 dBm */
-	OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(29));
+	OSMO_ASSERT(get_p_target_mdBm(trx, 2) == to_mdB(29));
 	/* at 2 steps (= 4dB), we expect 33-2-4-10=17*/
-	OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17));
+	OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 4) == to_mdB(17));
 }
 
 
@@ -157,9 +157,9 @@
 	/* at max_power_red = 2, we expect 38dBm */
 	OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(38));
 	/* at 1 step (of 2dB), we expect full 40-2-2=36 dBm */
-	OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(36));
+	OSMO_ASSERT(get_p_target_mdBm(trx, 2) == to_mdB(36));
 	/* at 2 steps (= 4dB), we expect 40-2-4-17=17*/
-	OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17));
+	OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 4) == to_mdB(17));
 }
 
 static void test_sbts2050(struct gsm_bts_trx *trx)
@@ -175,9 +175,9 @@
 	/* at max_power_red = 2, we expect 35dBm */
 	OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(35));
 	/* at 1 step (of 2dB), we expect full 37-2-2=33 dBm */
-	OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(33));
+	OSMO_ASSERT(get_p_target_mdBm(trx, 2) == to_mdB(33));
 	/* at 2 steps (= 4dB), we expect 37-2-4=31dBm */
-	OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(31));
+	OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 4) == to_mdB(31));
 }
 
 int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm)

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/18835
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I16cc50dfca102030380a06e16c234d5f6698f38f
Gerrit-Change-Number: 18835
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200616/bcd9e16f/attachment.htm>


More information about the gerrit-log mailing list