[PATCH] osmo-bts[master]: sysmobts: fully support trx_power_params

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Feb 7 19:17:44 UTC 2017


Review at  https://gerrit.osmocom.org/1767

sysmobts: fully support trx_power_params

The simplistic approach of sysmobts_get_nominal_power() is insufficient
to cope for devices that have an internal PA.  The Actual transceiver
board is driven to a certain level (0..23 dBm typically), and the
external PA must be handled independent of that.  Increasing the return
value of sysmobts_get_nominal_power() would result in the sysmoBTS
mainboard attempting to reach a higher power, which is wrong.

This change affects sysmoBTS 1020 and 1100.  It causes power-ramping to
be used by default.  For 1002 and 2050, no behavior change is expected.

Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4
---
M src/osmo-bts-sysmo/l1_if.c
M src/osmo-bts-sysmo/sysmobts_vty.c
M src/osmo-bts-sysmo/utils.c
M src/osmo-bts-sysmo/utils.h
M tests/tx_power/tx_power_test.c
5 files changed, 44 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/67/1767/1

diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
index c021368..8eb6fcc 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -51,6 +51,7 @@
 #include <osmo-bts/l1sap.h>
 #include <osmo-bts/msg_utils.h>
 #include <osmo-bts/dtx_dl_amr_fsm.h>
+#include <osmo-bts/tx_power.h>
 
 #include <sysmocom/femtobts/superfemto.h>
 #include <sysmocom/femtobts/gsml1prim.h>
@@ -1309,7 +1310,7 @@
 			LOGP(DL1C, LOGL_INFO, "Using external attenuator.\n");
 			sysp->u.activateRfReq.rfTrx.u8UseExtAtten = 1;
 			sysp->u.activateRfReq.rfTrx.fMaxTxPower =
-					sysmobts_get_nominal_power(trx);
+				(float) get_p_trxout_target_mdBm(trx, 0) / 1000;
 		}
 #endif /* 2.2.0 */
 #if SUPERFEMTO_API_VERSION >= SUPERFEMTO_API(3,8,1)
@@ -1797,6 +1798,44 @@
 
 #endif
 
+static void set_power_param(struct trx_power_params *out,
+			    int trx_p_max_out_dBm,
+			    int int_pa_nominal_gain_dB)
+{
+	out->trx_p_max_out_mdBm = to_mdB(trx_p_max_out_dBm);
+	out->pa.nominal_gain_mdB = to_mdB(int_pa_nominal_gain_dB);
+}
+
+static void fill_trx_power_params(struct gsm_bts_trx *trx,
+				 struct phy_instance *pinst)
+{
+	struct femtol1_hdl *fl1h = pinst->u.sysmobts.hdl;
+
+	switch (fl1h->hw_info.model_nr) {
+	case 1020:
+		set_power_param(&trx->power_params, 23, 10);
+		break;
+	case 1100:
+		set_power_param(&trx->power_params, 23, 17);
+		break;
+	case 2050:
+		set_power_param(&trx->power_params, 37, 0);
+		break;
+	default:
+		LOGP(DL1C, LOGL_NOTICE, "Unknown/Unsupported "
+		     "sysmoBTS Model Number %u\n",
+		     fl1h->hw_info.model_nr);
+		/* fall-through */
+	case 0xffff:
+		/* sysmoBTS 1002 without any setting in EEPROM */
+		LOGP(DL1C, LOGL_NOTICE, "Assuming 1002 for sysmoBTS "
+			"Model number %u\n", fl1h->hw_info.model_nr);
+	case 1002:
+		set_power_param(&trx->power_params, 23, 0);
+	}
+}
+
+
 int bts_model_phy_link_open(struct phy_link *plink)
 {
 	struct phy_instance *pinst = phy_instance_by_num(plink, 0);
@@ -1812,16 +1851,17 @@
 		return -EIO;
 	}
 
+	fill_trx_power_params(pinst->trx, pinst);
+
 	bts = pinst->trx->bts;
 	if (pinst->trx == bts->c0) {
 		int rc;
-		rc = sysmobts_get_nominal_power(bts->c0);
+		rc = get_p_max_out_mdBm(bts->c0);
 		if (rc < 0) {
 			LOGP(DL1C, LOGL_NOTICE, "Cannot determine nominal "
 			     "transmit power. Assuming 23dBm.\n");
 		}
 		bts->c0->nominal_power = rc;
-		bts->c0->power_params.trx_p_max_out_mdBm = to_mdB(rc);
 	}
 
 	phy_link_state_set(plink, PHY_LINK_CONNECTED);
diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c
index e67d8be..a1e6555 100644
--- a/src/osmo-bts-sysmo/sysmobts_vty.c
+++ b/src/osmo-bts-sysmo/sysmobts_vty.c
@@ -438,7 +438,7 @@
 
 void bts_model_config_write_trx(struct vty *vty, struct gsm_bts_trx *trx)
 {
-	if (trx->nominal_power != sysmobts_get_nominal_power(trx))
+	if (trx->nominal_power != get_p_max_out_mdBm(trx))
 		vty_out(vty, "  nominal-tx-power %d%s", trx->nominal_power,
 			VTY_NEWLINE);
 }
diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c
index a636ae1..be6051a 100644
--- a/src/osmo-bts-sysmo/utils.c
+++ b/src/osmo-bts-sysmo/utils.c
@@ -112,29 +112,3 @@
 	/* give up */
 	return -1;
 }
-
-int sysmobts_get_nominal_power(struct gsm_bts_trx *trx)
-{
-	struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx);
-
-	switch (fl1h->hw_info.model_nr) {
-	case 0:
-	case 0xffff:
-		/* old units have empty flash where the model number is
-		 * stored in later units */
-	case 1002:
-		/* 200mW (23 dBm) nominal power */
-		return 23;
-	case 2050:
-		/* 5W(37dBm) per TRX. This could be raiesd to 10W(40dBm)
-		 * if the second TRX is not used. */
-		return 37;
-	default:
-		LOGP(DL1C, LOGL_ERROR, "Model number %u/0x%x not known.\n",
-			fl1h->hw_info.model_nr, fl1h->hw_info.model_nr);
-		break;
-	}
-	return -1;
-}
-
-
diff --git a/src/osmo-bts-sysmo/utils.h b/src/osmo-bts-sysmo/utils.h
index 58e3324..45908d5 100644
--- a/src/osmo-bts-sysmo/utils.h
+++ b/src/osmo-bts-sysmo/utils.h
@@ -9,6 +9,4 @@
 int band_femto2osmo(GsmL1_FreqBand_t band);
 
 int sysmobts_select_femto_band(struct gsm_bts_trx *trx, uint16_t arfcn);
-
-int sysmobts_get_nominal_power(struct gsm_bts_trx *trx);
 #endif
diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c
index 606fe3e..f9e4ae9 100644
--- a/tests/tx_power/tx_power_test.c
+++ b/tests/tx_power/tx_power_test.c
@@ -52,7 +52,6 @@
 	.user_gain_mdB = 0,
 	.pa = {
 		.nominal_gain_mdB = to_mdB(10),
-		.calib.gain_mdB = { to_mdB(10), },
 	},
 	.user_pa = {
 		.nominal_gain_mdB = 0,
@@ -67,7 +66,6 @@
 	.user_gain_mdB = 0,
 	.pa = {
 		.nominal_gain_mdB = to_mdB(17),
-		.calib.gain_mdB = { to_mdB(17), },
 	},
 	.user_pa = {
 		.nominal_gain_mdB = 0,

-- 
To view, visit https://gerrit.osmocom.org/1767
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list