Timur Davydov has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/42698?usp=email )
Change subject: trx: handle synchronous TRX control callbacks in provision FSM
......................................................................
trx: handle synchronous TRX control callbacks in provision FSM
Set *_sent flags before issuing TRX control commands to ensure
correct state when responses are delivered synchronously
(e.g. WebUSB callback path)
Also guard FSM state handling in st_open_poweroff() to avoid
duplicate transitions if state was already changed by a
synchronous response
No functional change for asynchronous (socket-based) backends
Change-Id: I50c95e3796839e9fe721bff6f96fed4c490c6018
---
M src/osmo-bts-trx/trx_provision_fsm.c
1 file changed, 15 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/98/42698/1
diff --git a/src/osmo-bts-trx/trx_provision_fsm.c b/src/osmo-bts-trx/trx_provision_fsm.c
index 617dab3..b1ec0a4 100644
--- a/src/osmo-bts-trx/trx_provision_fsm.c
+++ b/src/osmo-bts-trx/trx_provision_fsm.c
@@ -181,16 +181,18 @@
}
/* before power on */
+ /* NOTE: flags are set BEFORE issuing the command so that synchronous
+ * callback paths (e.g. WebUSB) see the correct sent/acked state. */
if (l1h->config.arfcn_valid) {
if (!l1h->config.rxtune_sent) {
- trx_if_cmd_rxtune(l1h, l1h->config.arfcn, l1if_rxtune_cb);
l1h->config.rxtune_sent = true;
l1h->config.rxtune_acked = false;
+ trx_if_cmd_rxtune(l1h, l1h->config.arfcn, l1if_rxtune_cb);
}
if (!l1h->config.txtune_sent) {
- trx_if_cmd_txtune(l1h, l1h->config.arfcn, l1if_txtune_cb);
l1h->config.txtune_sent = true;
l1h->config.txtune_acked = false;
+ trx_if_cmd_txtune(l1h, l1h->config.arfcn, l1if_txtune_cb);
}
if (l1h->config.txtune_acked) {
/* After TXTUNE is sent to TRX, get the tx nominal power
@@ -199,23 +201,23 @@
* power (because TRX may not support the command or
* provide broken values) */
if (!l1h->config.nominal_power_set_by_vty && !l1h->config.nomtxpower_sent) {
- trx_if_cmd_getnompower(l1h, l1if_getnompower_cb);
l1h->config.nomtxpower_sent = true;
l1h->config.nomtxpower_acked = false;
+ trx_if_cmd_getnompower(l1h, l1if_getnompower_cb);
}
}
}
if (!pinst->phy_link->u.osmotrx.use_legacy_setbsic &&
l1h->config.tsc_valid && !l1h->config.tsc_sent) {
- trx_if_cmd_settsc(l1h, l1h->config.tsc, l1if_settsc_cb);
l1h->config.tsc_sent = true;
l1h->config.tsc_acked = false;
+ trx_if_cmd_settsc(l1h, l1h->config.tsc, l1if_settsc_cb);
}
if (pinst->phy_link->u.osmotrx.use_legacy_setbsic &&
l1h->config.bsic_valid && !l1h->config.bsic_sent) {
- trx_if_cmd_setbsic(l1h, l1h->config.bsic, l1if_setbsic_cb);
l1h->config.bsic_sent = true;
l1h->config.bsic_acked = false;
+ trx_if_cmd_setbsic(l1h, l1h->config.bsic, l1if_setbsic_cb);
}
/* Once the nominal Tx power is known, apply the initial Tx power attenuation
* before the transceiver is powered on. Otherwise it will be transmitting
@@ -225,9 +227,9 @@
int initial_mdBm = power_ramp_initial_power_mdBm(pinst->trx);
int power_att_dB = (get_p_max_out_mdBm(pinst->trx) - initial_mdBm) / 1000;
- trx_if_cmd_setpower_att(l1h, power_att_dB, l1if_setpower_att_cb);
l1h->config.setpower_sent = true;
l1h->config.setpower_acked = false;
+ trx_if_cmd_setpower_att(l1h, power_att_dB, l1if_setpower_att_cb);
}
/* Ask transceiver to use the newest TRXD PDU version if not using it yet */
@@ -239,8 +241,8 @@
l1h->config.trxd_pdu_ver_use = 0;
l1h->config.setformat_acked = true;
} else {
- trx_if_cmd_setformat(l1h, l1h->config.trxd_pdu_ver_req, l1if_setformat_cb);
l1h->config.setformat_acked = false;
+ trx_if_cmd_setformat(l1h, l1h->config.trxd_pdu_ver_req, l1if_setformat_cb);
}
}
return 0;
@@ -527,6 +529,12 @@
l1if_provision_transceiver_trx(l1h);
+ /* If the FSM state was already changed by synchronous response
+ * processing (e.g. WebUSB callback path), skip further handling
+ * to avoid duplicate state transitions. */
+ if (fi->state != TRX_PROV_ST_OPEN_POWEROFF)
+ return;
+
if (l1h->phy_inst->num == 0) {
waiting_other_trx = !trx_other_trx0_ready(l1h);
} else {
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/42698?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I50c95e3796839e9fe721bff6f96fed4c490c6018
Gerrit-Change-Number: 42698
Gerrit-PatchSet: 1
Gerrit-Owner: Timur Davydov <dtv.comp(a)gmail.com>