trx_provision_fsm: poweronoff_sent flag: track POWERON and POWEROFF separately

It helps better understanding the code, and will allow handling
situations where for instance a POWERON in in transit while the BTS is
instructed to shutdown, hence a POWEROFF needs to be sent.

Change-Id: Iaf62217ceab7420afa4140cba61e1c2f983c61b4
This commit is contained in:
Pau Espin 2021-10-04 12:44:03 +02:00 committed by pespin
parent 582d9cf0d5
commit 0d8f51f1a5
2 changed files with 11 additions and 8 deletions

View File

@ -50,7 +50,8 @@ struct phy_link {
bool use_legacy_setbsic;
uint8_t trxd_pdu_ver_max; /* Maximum TRXD PDU version to negotiate */
bool powered; /* last POWERON (true) or POWEROFF (false) confirmed */
bool poweronoff_sent; /* is there a POWERON/POWEROFF in transit? (one or the other based on ->powered) */
bool poweron_sent; /* is there a POWERON in transit? */
bool poweroff_sent; /* is there a POWEROFF in transit? */
} osmotrx;
struct {
char *mcast_dev; /* Network device for multicast */

View File

@ -50,12 +50,14 @@ static void l1if_poweronoff_cb(struct trx_l1h *l1h, bool poweronoff, int rc)
struct phy_link *plink = pinst->phy_link;
plink->u.osmotrx.powered = poweronoff;
plink->u.osmotrx.poweronoff_sent = false;
if (poweronoff)
if (poweronoff) {
plink->u.osmotrx.poweron_sent = false;
osmo_fsm_inst_dispatch(l1h->provision_fi, TRX_PROV_EV_POWERON_CNF, (void*)(intptr_t)rc);
else
} else {
plink->u.osmotrx.poweroff_sent = false;
osmo_fsm_inst_dispatch(l1h->provision_fi, TRX_PROV_EV_POWEROFF_CNF, (void*)(intptr_t)rc);
}
}
@ -520,7 +522,7 @@ static void st_open_wait_power_cnf_on_enter(struct osmo_fsm_inst *fi, uint32_t p
struct phy_instance *pinst = l1h->phy_inst;
trx_if_cmd_poweron(l1h, l1if_poweronoff_cb);
pinst->phy_link->u.osmotrx.poweronoff_sent = true;
pinst->phy_link->u.osmotrx.poweron_sent = true;
}
static void st_open_wait_power_cnf(struct osmo_fsm_inst *fi, uint32_t event, void *data)
@ -588,9 +590,9 @@ static void st_open_poweron(struct osmo_fsm_inst *fi, uint32_t event, void *data
switch (event) {
case TRX_PROV_EV_CLOSE:
/* power off transceiver, if not already */
if (pinst->num == 0 && plink->u.osmotrx.powered && !plink->u.osmotrx.poweronoff_sent) {
trx_if_cmd_poweroff(l1h, l1if_poweronoff_cb);
plink->u.osmotrx.poweronoff_sent = true;
if (pinst->num == 0 && plink->u.osmotrx.powered && !plink->u.osmotrx.poweroff_sent) {
trx_if_cmd_poweroff(l1h, l1if_poweronoff_cb);
plink->u.osmotrx.poweroff_sent = true;
}
trx_prov_fsm_state_chg(fi, TRX_PROV_ST_OPEN_WAIT_POWEROFF_CNF);
break;