trxcon: move FBSB state from struct l1ctl_link to trxcon_inst

Ideally, FBSB procedure should be implemented as a state of trxcon's
FSM.  For now let's simply move the related fields to trxcon_inst.
Remove l1ctl_shutdown_cb() as it's not needed anymore.

Change-Id: I92b50cf1bb36886fbe3d6460af3c0b1c57256ae8
This commit is contained in:
Vadim Yanitskiy 2022-07-18 03:52:19 +07:00
parent 27900b3a2d
commit a89492a4dd
6 changed files with 17 additions and 31 deletions

View File

@ -8,7 +8,6 @@
/* Event handlers */
int l1ctl_rx_cb(struct l1ctl_link *l1l, struct msgb *msg);
void l1ctl_shutdown_cb(struct l1ctl_link *l1l);
int l1ctl_tx_fbsb_conf(struct l1ctl_link *l1l, uint8_t result,
const struct l1ctl_info_dl *dl_info, uint8_t bsic);

View File

@ -29,13 +29,6 @@ struct l1ctl_link {
/* Some private data */
void *priv;
/* L1CTL handlers specific */
struct osmo_timer_list fbsb_timer;
bool fbsb_conf_sent;
/* Shutdown callback */
void (*shutdown_cb)(struct l1ctl_link *l1l);
};
struct l1ctl_link *l1ctl_link_init(void *tall_ctx, const char *sock_path);

View File

@ -29,6 +29,10 @@ struct trxcon_inst {
/* L1/L2 interfaces */
struct trx_instance *trx;
struct l1ctl_link *l1l;
/* TODO: implement this as an FSM state with timeout */
struct osmo_timer_list fbsb_timer;
bool fbsb_conf_sent;
};
struct trxcon_inst *trxcon_inst_alloc(void *ctx);

View File

@ -167,6 +167,7 @@ static struct l1ctl_fbsb_conf *fbsb_conf_make(struct msgb *msg, uint8_t result,
int l1ctl_tx_fbsb_conf(struct l1ctl_link *l1l, uint8_t result,
const struct l1ctl_info_dl *dl_info, uint8_t bsic)
{
struct trxcon_inst *trxcon = l1l->priv;
struct l1ctl_fbsb_conf *conf;
struct msgb *msg;
@ -182,11 +183,11 @@ int l1ctl_tx_fbsb_conf(struct l1ctl_link *l1l, uint8_t result,
conf->initial_freq_err = 0;
/* Ask SCH handler not to send L1CTL_FBSB_CONF anymore */
l1l->fbsb_conf_sent = true;
trxcon->fbsb_conf_sent = true;
/* Abort FBSB expire timer */
if (osmo_timer_pending(&l1l->fbsb_timer))
osmo_timer_del(&l1l->fbsb_timer);
if (osmo_timer_pending(&trxcon->fbsb_timer))
osmo_timer_del(&trxcon->fbsb_timer);
return l1ctl_link_send(l1l, msg);
}
@ -316,7 +317,7 @@ static void fbsb_timer_cb(void *data)
fbsb_conf_make(msg, 255, 0);
/* Ask SCH handler not to send L1CTL_FBSB_CONF anymore */
l1l->fbsb_conf_sent = true;
trxcon->fbsb_conf_sent = true;
l1ctl_link_send(l1l, msg);
}
@ -353,7 +354,7 @@ static int l1ctl_rx_fbsb_req(struct l1ctl_link *l1l, struct msgb *msg)
l1sched_configure_ts(trxcon->sched, 0, ch_config);
/* Ask SCH handler to send L1CTL_FBSB_CONF */
l1l->fbsb_conf_sent = false;
trxcon->fbsb_conf_sent = false;
/* Only if current ARFCN differs */
if (trxcon->trx->band_arfcn != band_arfcn) {
@ -371,10 +372,10 @@ static int l1ctl_rx_fbsb_req(struct l1ctl_link *l1l, struct msgb *msg)
trx_if_cmd_poweron(trxcon->trx);
/* Start FBSB expire timer */
l1l->fbsb_timer.data = l1l;
l1l->fbsb_timer.cb = fbsb_timer_cb;
trxcon->fbsb_timer.data = l1l;
trxcon->fbsb_timer.cb = fbsb_timer_cb;
LOGP(DL1C, LOGL_INFO, "Starting FBSB timer %u ms\n", timeout * GSM_TDMA_FN_DURATION_uS / 1000);
osmo_timer_schedule(&l1l->fbsb_timer, 0,
osmo_timer_schedule(&trxcon->fbsb_timer, 0,
timeout * GSM_TDMA_FN_DURATION_uS);
exit:
@ -902,10 +903,3 @@ int l1ctl_rx_cb(struct l1ctl_link *l1l, struct msgb *msg)
return -EINVAL;
}
}
void l1ctl_shutdown_cb(struct l1ctl_link *l1l)
{
/* Abort FBSB expire timer */
if (osmo_timer_pending(&l1l->fbsb_timer))
osmo_timer_del(&l1l->fbsb_timer);
}

View File

@ -265,9 +265,6 @@ struct l1ctl_link *l1ctl_link_init(void *tall_ctx, const char *sock_path)
return NULL;
}
/* Bind shutdown handler */
l1l->shutdown_cb = l1ctl_shutdown_cb;
/**
* To be able to accept first connection and
* drop others, it should be set to -1
@ -287,10 +284,6 @@ void l1ctl_link_shutdown(struct l1ctl_link *l1l)
LOGP(DL1C, LOGL_NOTICE, "Shutdown L1CTL link\n");
/* Call shutdown callback */
if (l1l->shutdown_cb != NULL)
l1l->shutdown_cb(l1l);
listen_bfd = &l1l->listen_bfd;
/* Check if we have an established connection */

View File

@ -164,7 +164,7 @@ int l1sched_handle_data_ind(struct l1sched_lchan_state *lchan,
break;
case L1SCHED_DT_OTHER:
if (lchan->type == L1SCHED_SCH) {
if (trxcon->l1l->fbsb_conf_sent)
if (trxcon->fbsb_conf_sent)
return 0;
rc = l1ctl_tx_fbsb_conf(trxcon->l1l, 0, &dl_hdr, sched->bsic);
break;
@ -371,6 +371,9 @@ void trxcon_inst_free(struct trxcon_inst *trxcon)
if (trxcon->trx != NULL)
trx_if_close(trxcon->trx);
if (osmo_timer_pending(&trxcon->fbsb_timer))
osmo_timer_del(&trxcon->fbsb_timer);
if (trxcon->fi != NULL)
osmo_fsm_inst_free(trxcon->fi);
talloc_free(trxcon);