diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-11-13 19:31:50 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-11-20 10:37:58 +0100 |
commit | 9d17840f83fa0c460098fc5b142d2f8b767fa501 (patch) | |
tree | f9a0bd5150450da78f8ae4055e73afd24150cb53 | |
parent | fc2ff394e0a1b2325bdadaa0699bf8e8d0c716bb (diff) |
bts-trx: setup timer once at creation time
The setup is only needed once, so no need to set it every time we want
to schedule it.
Furthermore, it will ease new code introduced in follow-up patches,
which will schedule this timer under some circumstances without need to
send a message at the same time (because re-try of a cmd after a delay
is wanted).
This commit adds an alloc function and an init function to keep
different parts of the code decoupled and avoid exposing more
implementation details between them (like exposing the trx_if timer).
Change-Id: I3b6461d0130d25284e673c5efce0b3832c48bbb5
-rw-r--r-- | src/osmo-bts-trx/l1_if.c | 8 | ||||
-rw-r--r-- | src/osmo-bts-trx/l1_if.h | 1 | ||||
-rw-r--r-- | src/osmo-bts-trx/main.c | 3 | ||||
-rw-r--r-- | src/osmo-bts-trx/trx_if.c | 10 | ||||
-rw-r--r-- | src/osmo-bts-trx/trx_if.h | 1 |
5 files changed, 17 insertions, 6 deletions
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c index faff3a00..b4ca54f0 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -58,6 +58,14 @@ static const uint8_t transceiver_chan_types[_GSM_PCHAN_MAX] = { [GSM_PCHAN_UNKNOWN] = 0, }; +struct trx_l1h *trx_l1h_alloc(void *tall_ctx, struct phy_instance *pinst) +{ + struct trx_l1h *l1h; + l1h = talloc_zero(tall_ctx, struct trx_l1h); + l1h->phy_inst = pinst; + trx_if_init(l1h); + return l1h; +} static void check_transceiver_availability_trx(struct trx_l1h *l1h, int avail) { diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h index 77c5936c..165f9d81 100644 --- a/src/osmo-bts-trx/l1_if.h +++ b/src/osmo-bts-trx/l1_if.h @@ -64,6 +64,7 @@ struct trx_l1h { struct l1sched_trx l1s; }; +struct trx_l1h *trx_l1h_alloc(void *tall_ctx, struct phy_instance *pinst); int check_transceiver_availability(struct gsm_bts *bts, int avail); int l1if_provision_transceiver_trx(struct trx_l1h *l1h); int l1if_provision_transceiver(struct gsm_bts *bts); diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c index 98f460eb..9529190e 100644 --- a/src/osmo-bts-trx/main.c +++ b/src/osmo-bts-trx/main.c @@ -139,8 +139,7 @@ void bts_model_phy_link_set_defaults(struct phy_link *plink) void bts_model_phy_instance_set_defaults(struct phy_instance *pinst) { struct trx_l1h *l1h; - l1h = talloc_zero(tall_bts_ctx, struct trx_l1h); - l1h->phy_inst = pinst; + l1h = trx_l1h_alloc(tall_bts_ctx, pinst); pinst->u.osmotrx.hdl = l1h; l1h->config.power_oml = 1; diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c index 4bcdfc69..b409d517 100644 --- a/src/osmo-bts-trx/trx_if.c +++ b/src/osmo-bts-trx/trx_if.c @@ -140,8 +140,6 @@ static int trx_clk_read_cb(struct osmo_fd *ofd, unsigned int what) * TRX ctrl socket */ -static void trx_ctrl_timer_cb(void *data); - /* send first ctrl message and start timer */ static void trx_ctrl_send(struct trx_l1h *l1h) { @@ -162,8 +160,6 @@ static void trx_ctrl_send(struct trx_l1h *l1h) send(l1h->trx_ofd_ctrl.fd, buf, len+1, 0); /* start timer */ - l1h->trx_ctrl_timer.cb = trx_ctrl_timer_cb; - l1h->trx_ctrl_timer.data = l1h; osmo_timer_schedule(&l1h->trx_ctrl_timer, 2, 0); } @@ -184,6 +180,12 @@ static void trx_ctrl_timer_cb(void *data) trx_ctrl_send(l1h); } +void trx_if_init(struct trx_l1h *l1h) +{ + l1h->trx_ctrl_timer.cb = trx_ctrl_timer_cb; + l1h->trx_ctrl_timer.data = l1h; +} + /*! Send a new TRX control command. * \param[inout] l1h TRX Layer1 handle to which to send command * \param[in] criticial diff --git a/src/osmo-bts-trx/trx_if.h b/src/osmo-bts-trx/trx_if.h index b1610441..206f5e54 100644 --- a/src/osmo-bts-trx/trx_if.h +++ b/src/osmo-bts-trx/trx_if.h @@ -14,6 +14,7 @@ struct trx_ctrl_msg { int critical; }; +void trx_if_init(struct trx_l1h *l1h); int trx_if_cmd_poweroff(struct trx_l1h *l1h); int trx_if_cmd_poweron(struct trx_l1h *l1h); int trx_if_cmd_settsc(struct trx_l1h *l1h, uint8_t tsc); |