summaryrefslogtreecommitdiffstats
path: root/src/host/trxcon
diff options
context:
space:
mode:
Diffstat (limited to 'src/host/trxcon')
-rw-r--r--src/host/trxcon/l1ctl_link.c15
-rw-r--r--src/host/trxcon/l1ctl_link.h3
-rw-r--r--src/host/trxcon/trx_if.c14
-rw-r--r--src/host/trxcon/trx_if.h2
-rw-r--r--src/host/trxcon/trxcon.c4
5 files changed, 22 insertions, 16 deletions
diff --git a/src/host/trxcon/l1ctl_link.c b/src/host/trxcon/l1ctl_link.c
index 0b01d729..5a22c7ee 100644
--- a/src/host/trxcon/l1ctl_link.c
+++ b/src/host/trxcon/l1ctl_link.c
@@ -177,7 +177,8 @@ static int l1ctl_link_accept(struct osmo_fd *bfd, unsigned int flags)
}
osmo_fsm_inst_state_chg(l1l->fsm, L1CTL_STATE_CONNECTED, 0, 0);
- osmo_fsm_inst_dispatch(trxcon_fsm, TRXCON_EV_L1CTL_CONNECT, NULL);
+ osmo_fsm_inst_dispatch(l1l->fsm->proc.parent,
+ TRXCON_EV_L1CTL_CONNECT, NULL);
LOGP(DL1C, LOGL_NOTICE, "L1CTL has a new connection\n");
@@ -224,12 +225,14 @@ int l1ctl_link_close_conn(struct l1ctl_link *l1l)
osmo_wqueue_clear(&l1l->wq);
osmo_fsm_inst_state_chg(l1l->fsm, L1CTL_STATE_IDLE, 0, 0);
- osmo_fsm_inst_dispatch(trxcon_fsm, TRXCON_EV_L1CTL_DISCONNECT, NULL);
+ osmo_fsm_inst_dispatch(l1l->fsm->proc.parent,
+ TRXCON_EV_L1CTL_DISCONNECT, NULL);
return 0;
}
-struct l1ctl_link *l1ctl_link_init(void *tall_ctx, const char *sock_path)
+struct l1ctl_link *l1ctl_link_init(struct osmo_fsm_inst *parent_fi,
+ const char *sock_path)
{
struct l1ctl_link *l1l;
struct osmo_fd *bfd;
@@ -237,15 +240,15 @@ struct l1ctl_link *l1ctl_link_init(void *tall_ctx, const char *sock_path)
LOGP(DL1C, LOGL_NOTICE, "Init L1CTL link (%s)\n", sock_path);
- l1l = talloc_zero(tall_ctx, struct l1ctl_link);
+ l1l = talloc_zero(parent_fi, struct l1ctl_link);
if (!l1l) {
LOGP(DL1C, LOGL_ERROR, "Failed to allocate memory\n");
return NULL;
}
/* Allocate a new dedicated state machine */
- l1l->fsm = osmo_fsm_inst_alloc(&l1ctl_fsm, l1l,
- NULL, LOGL_DEBUG, "l1ctl_link");
+ l1l->fsm = osmo_fsm_inst_alloc_child(&l1ctl_fsm,
+ parent_fi, TRXCON_EV_L1CTL_DISCONNECT);
if (l1l->fsm == NULL) {
LOGP(DTRX, LOGL_ERROR, "Failed to allocate an instance "
"of FSM '%s'\n", l1ctl_fsm.name);
diff --git a/src/host/trxcon/l1ctl_link.h b/src/host/trxcon/l1ctl_link.h
index da64419a..ceeaa308 100644
--- a/src/host/trxcon/l1ctl_link.h
+++ b/src/host/trxcon/l1ctl_link.h
@@ -41,7 +41,8 @@ struct l1ctl_link {
void (*shutdown_cb)(struct l1ctl_link *l1l);
};
-struct l1ctl_link *l1ctl_link_init(void *tall_ctx, const char *sock_path);
+struct l1ctl_link *l1ctl_link_init(struct osmo_fsm_inst *parent_fi,
+ const char *sock_path);
void l1ctl_link_shutdown(struct l1ctl_link *l1l);
int l1ctl_link_send(struct l1ctl_link *l1l, struct msgb *msg);
diff --git a/src/host/trxcon/trx_if.c b/src/host/trxcon/trx_if.c
index 79df6873..90240779 100644
--- a/src/host/trxcon/trx_if.c
+++ b/src/host/trxcon/trx_if.c
@@ -173,7 +173,8 @@ static void trx_ctrl_timer_cb(void *data)
if (++tcm->retry_cnt > 3) {
LOGP(DTRX, LOGL_NOTICE, "Transceiver offline\n");
osmo_fsm_inst_state_chg(trx->fsm, TRX_STATE_OFFLINE, 0, 0);
- osmo_fsm_inst_dispatch(trxcon_fsm, TRXCON_EV_TRX_DISCONNECT, NULL);
+ osmo_fsm_inst_dispatch(trx->fsm->proc.parent,
+ TRXCON_EV_TRX_DISCONNECT, NULL);
return;
}
@@ -514,7 +515,8 @@ static int trx_ctrl_read_cb(struct osmo_fd *ofd, unsigned int what)
rsp_error:
/* Notify higher layers about the problem */
- osmo_fsm_inst_dispatch(trxcon_fsm, TRXCON_EV_TRX_CTRL_ERROR, NULL);
+ osmo_fsm_inst_dispatch(trx->fsm->proc.parent,
+ TRXCON_EV_TRX_CTRL_ERROR, NULL);
return -EIO;
}
@@ -627,7 +629,7 @@ int trx_if_tx_burst(struct trx_instance *trx, uint8_t tn, uint32_t fn,
}
/* Init TRX interface (TRXC, TRXD sockets and FSM) */
-struct trx_instance *trx_if_open(void *tall_ctx,
+struct trx_instance *trx_if_open(struct osmo_fsm_inst *parent_fi,
const char *local_host, const char *remote_host,
uint16_t base_port)
{
@@ -638,15 +640,15 @@ struct trx_instance *trx_if_open(void *tall_ctx,
"(%s:%u)\n", remote_host, base_port);
/* Try to allocate memory */
- trx = talloc_zero(tall_ctx, struct trx_instance);
+ trx = talloc_zero(parent_fi, struct trx_instance);
if (!trx) {
LOGP(DTRX, LOGL_ERROR, "Failed to allocate memory\n");
return NULL;
}
/* Allocate a new dedicated state machine */
- trx->fsm = osmo_fsm_inst_alloc(&trx_fsm, trx,
- NULL, LOGL_DEBUG, "trx_interface");
+ trx->fsm = osmo_fsm_inst_alloc_child(&trx_fsm,
+ parent_fi, TRXCON_EV_TRX_DISCONNECT);
if (trx->fsm == NULL) {
LOGP(DTRX, LOGL_ERROR, "Failed to allocate an instance "
"of FSM '%s'\n", trx_fsm.name);
diff --git a/src/host/trxcon/trx_if.h b/src/host/trxcon/trx_if.h
index 0b3f36f7..81806697 100644
--- a/src/host/trxcon/trx_if.h
+++ b/src/host/trxcon/trx_if.h
@@ -52,7 +52,7 @@ struct trx_ctrl_msg {
int cmd_len;
};
-struct trx_instance *trx_if_open(void *tall_ctx,
+struct trx_instance *trx_if_open(struct osmo_fsm_inst *parent_fi,
const char *local_host, const char *remote_host, uint16_t port);
void trx_if_flush_ctrl(struct trx_instance *trx);
void trx_if_close(struct trx_instance *trx);
diff --git a/src/host/trxcon/trxcon.c b/src/host/trxcon/trxcon.c
index 8b177ba5..f9cd3e6d 100644
--- a/src/host/trxcon/trxcon.c
+++ b/src/host/trxcon/trxcon.c
@@ -214,13 +214,13 @@ int main(int argc, char **argv)
goto exit;
/* Init L1CTL server */
- app_data.l1l = l1ctl_link_init(tall_trxcon_ctx,
+ app_data.l1l = l1ctl_link_init(trxcon_fsm,
app_data.bind_socket);
if (app_data.l1l == NULL)
goto exit;
/* Init transceiver interface */
- app_data.trx = trx_if_open(tall_trxcon_ctx,
+ app_data.trx = trx_if_open(trxcon_fsm,
app_data.trx_bind_ip, app_data.trx_remote_ip,
app_data.trx_base_port);
if (!app_data.trx)