aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-05-26 19:18:22 +0200
committerpespin <pespin@sysmocom.de>2020-06-12 09:59:56 +0000
commitadf5d3aed267dc03861ef192e701b62186af44fc (patch)
treedd499c0dc170a1e84c50e15c20254df988fa0b60 /src
parentc579e674c740aee022951f8a26d2bcde609933cd (diff)
bts-trx: Implement power ramping during BTS bring up
The nominal transmit power is still only configurable manually from osmo-bts-trx VTY interface. Support to retrieve the nominal power from osmo-trx will come later. Change-Id: Ia7c353e4c199e0fc3bcab55c45a4abda2c66d2c1
Diffstat (limited to 'src')
-rw-r--r--src/osmo-bts-trx/l1_if.c44
-rw-r--r--src/osmo-bts-trx/l1_if.h5
-rw-r--r--src/osmo-bts-trx/main.c3
-rw-r--r--src/osmo-bts-trx/trx_if.c22
-rw-r--r--src/osmo-bts-trx/trx_if.h3
-rw-r--r--src/osmo-bts-trx/trx_vty.c67
6 files changed, 71 insertions, 73 deletions
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index b67d8faa..ff8e2936 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -177,6 +177,15 @@ static void l1if_poweronoff_cb(struct trx_l1h *l1h, bool poweronoff, int rc)
if (rc == 0 && pinst->phy_link->state != PHY_LINK_CONNECTED) {
trx_sched_clock_started(pinst->trx->bts);
phy_link_state_set(pinst->phy_link, PHY_LINK_CONNECTED);
+
+ /* Begin to ramp up the power on all TRX associated with this phy */
+ llist_for_each_entry(pinst, &plink->instances, list) {
+ struct gsm_bts_trx *trx = pinst->trx;
+ if (l1h->config.forced_max_power_red == -1)
+ power_ramp_start(trx, get_p_nominal_mdBm(trx), 0);
+ else
+ power_ramp_start(trx, get_p_max_out_mdBm(trx) - to_mdB(l1h->config.forced_max_power_red), 1);
+ }
} else if (rc != 0 && pinst->phy_link->state != PHY_LINK_SHUTDOWN) {
trx_sched_clock_stopped(pinst->trx->bts);
phy_link_state_set(pinst->phy_link, PHY_LINK_SHUTDOWN);
@@ -184,6 +193,16 @@ static void l1if_poweronoff_cb(struct trx_l1h *l1h, bool poweronoff, int rc)
}
}
+static void l1if_setpower_cb(struct trx_l1h *l1h, int power_att_db, int rc)
+{
+ struct phy_instance *pinst = l1h->phy_inst;
+ struct gsm_bts_trx *trx = pinst->trx;
+
+ LOGPPHI(pinst, DL1C, LOGL_DEBUG, "l1if_setpower_cb(power_att_db=%d, rc=%d)\n", power_att_db, rc);
+
+ power_trx_change_compl(trx, get_p_max_out_mdBm(trx) - to_mdB(power_att_db));
+}
+
/*
* transceiver provisioning
*/
@@ -249,10 +268,6 @@ int l1if_provision_transceiver_trx(struct trx_l1h *l1h)
trx_if_cmd_setrxgain(l1h, l1h->config.rxgain);
l1h->config.rxgain_sent = 1;
}
- if (l1h->config.power_valid && !l1h->config.power_sent) {
- trx_if_cmd_setpower(l1h, l1h->config.power);
- l1h->config.power_sent = 1;
- }
if (l1h->config.maxdly_valid && !l1h->config.maxdly_sent) {
trx_if_cmd_setmaxdly(l1h, l1h->config.maxdly);
l1h->config.maxdly_sent = 1;
@@ -279,7 +294,6 @@ int l1if_provision_transceiver_trx(struct trx_l1h *l1h)
plink->u.osmotrx.poweronoff_sent = true;
}
l1h->config.rxgain_sent = 0;
- l1h->config.power_sent = 0;
l1h->config.maxdly_sent = 0;
l1h->config.maxdlynb_sent = 0;
for (tn = 0; tn < TRX_NR_TS; tn++)
@@ -304,7 +318,6 @@ int l1if_provision_transceiver(struct gsm_bts *bts)
l1h->config.tsc_sent = 0;
l1h->config.bsic_sent = 0;
l1h->config.rxgain_sent = 0;
- l1h->config.power_sent = 0;
l1h->config.maxdly_sent = 0;
l1h->config.maxdlynb_sent = 0;
for (tn = 0; tn < TRX_NR_TS; tn++)
@@ -408,6 +421,7 @@ static uint8_t trx_set_trx(struct gsm_bts_trx *trx)
{
struct phy_instance *pinst = trx_phy_instance(trx);
struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
+ struct phy_link *plink = pinst->phy_link;
uint16_t arfcn = trx->arfcn;
if (l1h->config.arfcn != arfcn || !l1h->config.arfcn_valid) {
@@ -417,12 +431,11 @@ static uint8_t trx_set_trx(struct gsm_bts_trx *trx)
l1if_provision_transceiver_trx(l1h);
}
- if (l1h->config.power_oml) {
- l1h->config.power = trx->max_power_red;
- l1h->config.power_valid = 1;
- l1h->config.power_sent = 0;
- l1if_provision_transceiver_trx(l1h);
- }
+ /* Begin to ramp up the power if power reduction is set by OML and TRX
+ is already running. Otherwise skip, power ramping will be started
+ after TRX is running */
+ if (plink->u.osmotrx.powered && l1h->config.forced_max_power_red == -1)
+ power_ramp_start(pinst->trx, get_p_nominal_mdBm(pinst->trx), 0);
return 0;
}
@@ -802,9 +815,10 @@ int bts_model_oml_estab(struct gsm_bts *bts)
int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm)
{
-#warning "implement bts_model_change_power\n"
- LOGP(DL1C, LOGL_NOTICE, "Setting TRX output power not supported!\n");
- return 0;
+ struct phy_instance *pinst = trx_phy_instance(trx);
+ struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
+ int power_att = (get_p_max_out_mdBm(trx) - p_trxout_mdBm) / 1000;
+ return trx_if_cmd_setpower(l1h, power_att, l1if_setpower_cb);
}
int bts_model_ts_disconnect(struct gsm_bts_trx_ts *ts)
diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h
index 42452d24..46f2c187 100644
--- a/src/osmo-bts-trx/l1_if.h
+++ b/src/osmo-bts-trx/l1_if.h
@@ -73,10 +73,7 @@ struct trx_config {
uint8_t rxgain;
int rxgain_sent;
- int power_valid;
- uint8_t power;
- int power_oml;
- int power_sent;
+ int forced_max_power_red; /* -1 if not forced by VTY config (default) */
bool nominal_power_set_by_vty; /* whether nominal trx power was enforced/retreived from VTY config "nominal-tx-power" */
diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index bd3d0cb4..8fb67d21 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -129,6 +129,7 @@ int bts_model_init(struct gsm_bts *bts)
int bts_model_trx_init(struct gsm_bts_trx *trx)
{
+ trx->power_params.trx_p_max_out_mdBm = to_mdB(trx->bts->c0->nominal_power);
return 0;
}
@@ -150,7 +151,7 @@ void bts_model_phy_instance_set_defaults(struct phy_instance *pinst)
l1h = trx_l1h_alloc(tall_bts_ctx, pinst);
pinst->u.osmotrx.hdl = l1h;
- l1h->config.power_oml = 1;
+ l1h->config.forced_max_power_red = -1;
}
int main(int argc, char **argv)
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index 24d6b9b0..5e3bf917 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -303,9 +303,9 @@ int trx_if_cmd_setrxgain(struct trx_l1h *l1h, int db)
}
/*! Send "SETPOWER" command to TRX */
-int trx_if_cmd_setpower(struct trx_l1h *l1h, int db)
+int trx_if_cmd_setpower(struct trx_l1h *l1h, int power_att_db, trx_if_cmd_setpower_cb *cb)
{
- return trx_ctrl_cmd(l1h, 0, "SETPOWER", "%d", db);
+ return trx_ctrl_cmd_cb(l1h, 0, cb, "SETPOWER", "%d", power_att_db);
}
/*! Send "SETMAXDLY" command to TRX, i.e. maximum delay for RACH bursts */
@@ -544,6 +544,22 @@ static int trx_ctrl_rx_rsp_setformat(struct trx_l1h *l1h,
return 0;
}
+static int trx_ctrl_rx_rsp_setpower(struct trx_l1h *l1h, struct trx_ctrl_rsp *rsp)
+{
+ trx_if_cmd_setpower_cb *cb = (trx_if_cmd_setpower_cb*) rsp->cb;
+ struct phy_instance *pinst = l1h->phy_inst;
+ int power_att;
+
+ if (rsp->status)
+ LOGPPHI(pinst, DTRX, LOGL_ERROR, "transceiver SETPOWER failed with status %d\n",
+ rsp->status);
+ if (cb) {
+ sscanf(rsp->params, "%d", &power_att);
+ cb(l1h, power_att, rsp->status);
+ }
+ return 0;
+}
+
/* -EINVAL: unrecoverable error, exit BTS
* N > 0: try sending originating command again after N seconds
* 0: Done with response, get originating command out from send queue
@@ -562,6 +578,8 @@ static int trx_ctrl_rx_rsp(struct trx_l1h *l1h,
* so that's why we should use tcm instead of rsp. */
} else if (strcmp(tcm->cmd, "SETFORMAT") == 0) {
return trx_ctrl_rx_rsp_setformat(l1h, rsp);
+ } else if (strcmp(tcm->cmd, "SETPOWER") == 0) {
+ return trx_ctrl_rx_rsp_setpower(l1h, rsp);
}
if (rsp->status) {
diff --git a/src/osmo-bts-trx/trx_if.h b/src/osmo-bts-trx/trx_if.h
index fd0077d8..0630eb6e 100644
--- a/src/osmo-bts-trx/trx_if.h
+++ b/src/osmo-bts-trx/trx_if.h
@@ -15,6 +15,7 @@ struct trx_ctrl_msg {
typedef void trx_if_cmd_poweronoff_cb(struct trx_l1h *l1h, bool poweronoff, int rc);
typedef void trx_if_cmd_setslot_cb(struct trx_l1h *l1h, uint8_t tn, uint8_t type, int rc);
+typedef void trx_if_cmd_setpower_cb(struct trx_l1h *l1h, int power_att_db, int rc);
void trx_if_init(struct trx_l1h *l1h);
int trx_if_cmd_poweroff(struct trx_l1h *l1h, trx_if_cmd_poweronoff_cb *cb);
@@ -22,7 +23,7 @@ int trx_if_cmd_poweron(struct trx_l1h *l1h, trx_if_cmd_poweronoff_cb *cb);
int trx_if_cmd_settsc(struct trx_l1h *l1h, uint8_t tsc);
int trx_if_cmd_setbsic(struct trx_l1h *l1h, uint8_t bsic);
int trx_if_cmd_setrxgain(struct trx_l1h *l1h, int db);
-int trx_if_cmd_setpower(struct trx_l1h *l1h, int db);
+int trx_if_cmd_setpower(struct trx_l1h *l1h, int power_att_db, trx_if_cmd_setpower_cb *cb);
int trx_if_cmd_setmaxdly(struct trx_l1h *l1h, int dly);
int trx_if_cmd_setmaxdlynb(struct trx_l1h *l1h, int dly);
int trx_if_cmd_setslot(struct trx_l1h *l1h, uint8_t tn, uint8_t type, trx_if_cmd_setslot_cb *cb);
diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c
index 6dddfe20..b920c57e 100644
--- a/src/osmo-bts-trx/trx_vty.c
+++ b/src/osmo-bts-trx/trx_vty.c
@@ -97,6 +97,7 @@ static void show_phy_inst_single(struct vty *vty, struct phy_instance *pinst)
{
uint8_t tn;
struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
+ struct gsm_bts_trx *trx = pinst->trx;
vty_out(vty, "PHY Instance %s%s",
phy_instance_name(pinst), VTY_NEWLINE);
@@ -106,11 +107,9 @@ static void show_phy_inst_single(struct vty *vty, struct phy_instance *pinst)
l1h->config.rxgain, VTY_NEWLINE);
else
vty_out(vty, " rx-gain : undefined%s", VTY_NEWLINE);
- if (l1h->config.power_valid)
- vty_out(vty, " tx-attenuation : %d dB%s",
- l1h->config.power, VTY_NEWLINE);
- else
- vty_out(vty, " tx-attenuation : undefined%s", VTY_NEWLINE);
+ vty_out(vty, " tx-attenuation : %d dB%s",
+ (get_p_max_out_mdBm(trx) - get_p_actual_mdBm(trx, trx->power_params.p_total_tgt_mdBm))/1000,
+ VTY_NEWLINE);
if (l1h->config.maxdly_valid)
vty_out(vty, " maxdly : %d%s", l1h->config.maxdly,
VTY_NEWLINE);
@@ -171,6 +170,7 @@ DEFUN(cfg_trx_nominal_power, cfg_trx_nominal_power_cmd,
int val = atoi(argv[0]);
trx->nominal_power = val;
+ trx->power_params.trx_p_max_out_mdBm = to_mdB(trx->nominal_power);
l1h->config.nominal_power_set_by_vty = true;
return CMD_SUCCESS;
@@ -361,36 +361,19 @@ DEFUN(cfg_phyinst_rxgain, cfg_phyinst_rxgain_cmd,
}
DEFUN(cfg_phyinst_tx_atten, cfg_phyinst_tx_atten_cmd,
- "osmotrx tx-attenuation <0-50>",
- OSMOTRX_STR
- "Set the transmitter attenuation\n"
- "Fixed attenuation in dB, overriding OML\n")
-{
- struct phy_instance *pinst = vty->index;
- struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
-
- l1h->config.power = atoi(argv[0]);
- l1h->config.power_oml = 0;
- l1h->config.power_valid = 1;
- l1h->config.power_sent = 0;
- l1if_provision_transceiver_trx(l1h);
-
- return CMD_SUCCESS;
-}
-
-DEFUN(cfg_phyinst_tx_atten_oml, cfg_phyinst_tx_atten_oml_cmd,
- "osmotrx tx-attenuation oml",
+ "osmotrx tx-attenuation (oml|<0-50>)",
OSMOTRX_STR
"Set the transmitter attenuation\n"
- "Use NM_ATT_RF_MAXPOWR_R (max power reduction) from BSC via OML\n")
+ "Use NM_ATT_RF_MAXPOWR_R (max power reduction) from BSC via OML (default)\n"
+ "Fixed attenuation in dB, overriding OML (default)\n")
{
struct phy_instance *pinst = vty->index;
struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
- l1h->config.power_oml = 1;
- l1h->config.power_valid = 1;
- l1h->config.power_sent = 0;
- l1if_provision_transceiver_trx(l1h);
+ if (strcmp(argv[0], "oml") == 0)
+ l1h->config.forced_max_power_red = -1;
+ else
+ l1h->config.forced_max_power_red = atoi(argv[0]);
return CMD_SUCCESS;
}
@@ -407,18 +390,6 @@ DEFUN(cfg_phyinst_no_rxgain, cfg_phyinst_no_rxgain_cmd,
return CMD_SUCCESS;
}
-DEFUN(cfg_phyinst_no_tx_atten, cfg_phyinst_no_tx_atten_cmd,
- "no osmotrx tx-attenuation",
- NO_STR OSMOTRX_STR "Unset the transmitter attenuation\n")
-{
- struct phy_instance *pinst = vty->index;
- struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
-
- l1h->config.power_valid = 0;
-
- return CMD_SUCCESS;
-}
-
DEFUN(cfg_phyinst_no_maxdly, cfg_phyinst_no_maxdly_cmd,
"no osmotrx maxdly",
NO_STR OSMOTRX_STR
@@ -574,13 +545,11 @@ void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst
if (l1h->config.rxgain_valid)
vty_out(vty, " osmotrx rx-gain %d%s",
l1h->config.rxgain, VTY_NEWLINE);
- if (l1h->config.power_valid) {
- if (l1h->config.power_oml)
- vty_out(vty, " osmotrx tx-attenuation oml%s", VTY_NEWLINE);
- else
- vty_out(vty, " osmotrx tx-attenuation %d%s",
- l1h->config.power, VTY_NEWLINE);
- }
+ if (l1h->config.forced_max_power_red == -1)
+ vty_out(vty, " osmotrx tx-attenuation oml%s", VTY_NEWLINE);
+ else
+ vty_out(vty, " osmotrx tx-attenuation %d%s",
+ l1h->config.forced_max_power_red, VTY_NEWLINE);
if (l1h->config.maxdly_valid)
vty_out(vty, " osmotrx maxdly %d%s", l1h->config.maxdly, VTY_NEWLINE);
if (l1h->config.maxdlynb_valid)
@@ -637,9 +606,7 @@ int bts_model_vty_init(struct gsm_bts *bts)
install_element(PHY_INST_NODE, &cfg_phyinst_rxgain_cmd);
install_element(PHY_INST_NODE, &cfg_phyinst_tx_atten_cmd);
- install_element(PHY_INST_NODE, &cfg_phyinst_tx_atten_oml_cmd);
install_element(PHY_INST_NODE, &cfg_phyinst_no_rxgain_cmd);
- install_element(PHY_INST_NODE, &cfg_phyinst_no_tx_atten_cmd);
install_element(PHY_INST_NODE, &cfg_phyinst_slotmask_cmd);
install_element(PHY_INST_NODE, &cfg_phyinst_power_on_cmd);
install_element(PHY_INST_NODE, &cfg_phyinst_maxdly_cmd);