diff --git a/include/osmo-bts/signal.h b/include/osmo-bts/signal.h index c8168a260..8359f021e 100644 --- a/include/osmo-bts/signal.h +++ b/include/osmo-bts/signal.h @@ -15,4 +15,10 @@ enum signals_global { S_NEW_NSVC_ATTR, }; +struct nm_statechg_signal_data { + struct gsm_abis_mo *mo; + uint8_t old_state; + uint8_t new_state; +}; + #endif diff --git a/src/common/oml.c b/src/common/oml.c index f841853f2..30caad514 100644 --- a/src/common/oml.c +++ b/src/common/oml.c @@ -355,12 +355,16 @@ int oml_mo_state_chg(struct gsm_abis_mo *mo, int op_state, int avail_state, int mo->nm_state.availability = avail_state; } if (op_state != -1) { + struct nm_statechg_signal_data nsd; LOGP(DOML, LOGL_INFO, "%s OPER STATE %s -> %s\n", gsm_abis_mo_name(mo), abis_nm_opstate_name(mo->nm_state.operational), abis_nm_opstate_name(op_state)); + nsd.mo = mo; + nsd.old_state = mo->nm_state.operational; + nsd.new_state = op_state; mo->nm_state.operational = op_state; - osmo_signal_dispatch(SS_GLOBAL, S_NEW_OP_STATE, NULL); + osmo_signal_dispatch(SS_GLOBAL, S_NEW_OP_STATE, &nsd); } if (adm_state != -1) { LOGP(DOML, LOGL_INFO, "%s ADMIN STATE %s -> %s\n", diff --git a/src/osmo-bts-trx/trx_provision_fsm.c b/src/osmo-bts-trx/trx_provision_fsm.c index 39fb60815..52736adee 100644 --- a/src/osmo-bts-trx/trx_provision_fsm.c +++ b/src/osmo-bts-trx/trx_provision_fsm.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "l1_if.h" #include "trx_provision_fsm.h" @@ -314,6 +315,30 @@ static void trx_prov_fsm_apply_close(struct phy_link *plink, int rc) } } +static int trx_prov_fsm_signal_cb(unsigned int subsys, unsigned int signal, + void *hdlr_data, void *signal_data) +{ + struct nm_statechg_signal_data *nsd; + struct gsm_bts_trx *trx; + + if (subsys != SS_GLOBAL) + return -EINVAL; + + if (signal != S_NEW_OP_STATE) + return 0; + + nsd = (struct nm_statechg_signal_data *)signal_data; + + if (nsd->mo->obj_class != NM_OC_RADIO_CARRIER) + return 0; + + if (nsd->old_state != NM_OPSTATE_ENABLED && nsd->new_state == NM_OPSTATE_ENABLED) { + trx = gsm_objclass2obj(nsd->mo->bts, nsd->mo->obj_class, &nsd->mo->obj_inst); + l1if_trx_start_power_ramp(trx, NULL); + } + return 0; +} + ////////////////////////// // FSM STATE ACTIONS ////////////////////////// @@ -511,13 +536,6 @@ static void st_open_wait_power_cnf(struct osmo_fsm_inst *fi, uint32_t event, voi if (rc == 0 && plink->state != PHY_LINK_CONNECTED) { trx_sched_clock_started(pinst->trx->bts); phy_link_state_set(plink, PHY_LINK_CONNECTED); - - /* Begin to ramp up the power on all TRX associated with this phy */ - llist_for_each_entry(pinst, &plink->instances, list) { - if (pinst->trx->mo.nm_state.administrative == NM_STATE_UNLOCKED) - l1if_trx_start_power_ramp(pinst->trx, NULL); - } - trx_prov_fsm_state_chg(fi, TRX_PROV_ST_OPEN_POWERON); } else if (rc != 0 && plink->state != PHY_LINK_SHUTDOWN) { trx_sched_clock_stopped(pinst->trx->bts); @@ -709,4 +727,5 @@ struct osmo_fsm trx_prov_fsm = { static __attribute__((constructor)) void trx_prov_fsm_init(void) { OSMO_ASSERT(osmo_fsm_register(&trx_prov_fsm) == 0); + OSMO_ASSERT(osmo_signal_register_handler(SS_GLOBAL, trx_prov_fsm_signal_cb, NULL) == 0); }