phy_link: Introduce bts_model_phy_link_close() and use it in bts-trx

This step is required while turning off the BTS without killing the
process. Right now only osmo-bts-trx supports this feature, so this
function is only available and used by osmo-bts-trx.
Later on, when the feature is support more generally, we can move call
to this function to common place like bts_shutdown_fsm or alike.

Change-Id: I3253112700a31b85db82dc7ccadec8542bac745e
This commit is contained in:
Pau Espin 2021-09-20 17:59:21 +02:00 committed by pespin
parent 192390c797
commit dfedf2cb76
4 changed files with 22 additions and 4 deletions

View File

@ -88,6 +88,7 @@ order to specify which PHY instance is allocated to this specific TRX.
| common | abis_open() | Start of the A-bis connection to BSC
| common | phy_links_open() | Iterate over list of configured PHY links
| bts-specific | bts_model_phy_link_open() | Open each of the configured PHY links
| bts-specific | bts_model_phy_link_close() | Close each of the configured PHY links
| common | write_pid_file() | Generate the pid file
| common | osmo_daemonize() | Fork as daemon in background (if configured)
| common | bts_main() | Run main loop until global variable quit >= 2

View File

@ -174,6 +174,7 @@ static inline struct phy_instance *trx_phy_instance(const struct gsm_bts_trx *tr
}
int bts_model_phy_link_open(struct phy_link *plink);
int bts_model_phy_link_close(struct phy_link *plink);
#define LOGPPHL(plink, section, lvl, fmt, args...) LOGP(section, lvl, "%s: " fmt, phy_link_name(plink), ##args)
#define LOGPPHI(pinst, section, lvl, fmt, args...) LOGP(section, lvl, "%s: " fmt, phy_instance_name(pinst), ##args)

View File

@ -1341,6 +1341,23 @@ cleanup:
return -1;
}
/*! close the PHY link using TRX protocol */
int bts_model_phy_link_close(struct phy_link *plink)
{
bool clock_stopped = false;
struct phy_instance *pinst;
llist_for_each_entry(pinst, &plink->instances, list) {
if (!clock_stopped) {
clock_stopped = true;
trx_sched_clock_stopped(pinst->trx->bts);
}
trx_phy_inst_close(pinst);
}
trx_udp_close(&plink->u.osmotrx.trx_ofd_clk);
phy_link_state_set(plink, PHY_LINK_SHUTDOWN);
return 0;
}
/*! determine if the TRX for given handle is powered up */
int trx_if_powered(struct trx_l1h *l1h)
{

View File

@ -592,14 +592,13 @@ static void st_open_wait_poweroff_cnf(struct osmo_fsm_inst *fi, uint32_t event,
case TRX_PROV_EV_POWEROFF_CNF:
rc = (uint16_t)(intptr_t)data;
if (plink->state != PHY_LINK_SHUTDOWN) {
trx_sched_clock_stopped(pinst->trx->bts);
phy_link_state_set(plink, PHY_LINK_SHUTDOWN);
bts_model_phy_link_close(plink);
/* Notify TRX close on all TRX associated with this phy */
llist_for_each_entry(pinst, &plink->instances, list) {
bts_model_trx_close_cb(pinst->trx, rc);
}
trx_prov_fsm_state_chg(fi, TRX_PROV_ST_OPEN_POWEROFF);
trx_prov_fsm_state_chg(fi, TRX_PROV_ST_CLOSED);
}
break;
default:
@ -661,7 +660,7 @@ static struct osmo_fsm_state trx_prov_fsm_states[] = {
.in_event_mask =
X(TRX_PROV_EV_POWEROFF_CNF),
.out_state_mask =
X(TRX_PROV_ST_OPEN_POWEROFF),
X(TRX_PROV_ST_CLOSED),
.name = "OPEN_WAIT_POWEROFF_CNF",
.action = st_open_wait_poweroff_cnf,
},