Change in osmo-bts[master]: bts-trx: setup timer once at creation time

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Tue Nov 20 16:33:10 UTC 2018


Pau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/11766 )

Change subject: bts-trx: setup timer once at creation time
......................................................................

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
---
M src/osmo-bts-trx/l1_if.c
M src/osmo-bts-trx/l1_if.h
M src/osmo-bts-trx/main.c
M src/osmo-bts-trx/trx_if.c
M src/osmo-bts-trx/trx_if.h
5 files changed, 17 insertions(+), 6 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index faff3a0..b4ca54f 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -58,6 +58,14 @@
 	[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 77c5936..165f9d8 100644
--- a/src/osmo-bts-trx/l1_if.h
+++ b/src/osmo-bts-trx/l1_if.h
@@ -64,6 +64,7 @@
 	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 98f460e..9529190 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -139,8 +139,7 @@
 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 4bcdfc6..b409d51 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -140,8 +140,6 @@
  * 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 @@
 	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 @@
 	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 b161044..206f5e5 100644
--- a/src/osmo-bts-trx/trx_if.h
+++ b/src/osmo-bts-trx/trx_if.h
@@ -14,6 +14,7 @@
 	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);

-- 
To view, visit https://gerrit.osmocom.org/11766
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3b6461d0130d25284e673c5efce0b3832c48bbb5
Gerrit-Change-Number: 11766
Gerrit-PatchSet: 4
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-CC: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181120/2b758988/attachment.html>


More information about the gerrit-log mailing list