This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-bts/+/15614 )
Change subject: bts-trx: Allocate struct osmo_trx_clock_state as part of bts-trx private data
......................................................................
bts-trx: Allocate struct osmo_trx_clock_state as part of bts-trx private data
Related: OS#4215
Change-Id: I9b7ffb51423ada74b8be347c57eade08f307f88f
---
M src/osmo-bts-trx/l1_if.h
M src/osmo-bts-trx/main.c
M src/osmo-bts-trx/scheduler_trx.c
3 files changed, 52 insertions(+), 44 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h
index 87df951..29bd246 100644
--- a/src/osmo-bts-trx/l1_if.h
+++ b/src/osmo-bts-trx/l1_if.h
@@ -5,6 +5,50 @@
#include <osmo-bts/phy_link.h>
#include "trx_if.h"
+/*
+ * TRX frame clock handling
+ *
+ * In a "normal" synchronous PHY layer, we would be polled every time
+ * the PHY needs data for a given frame number. However, the
+ * OpenBTS-inherited TRX protocol works differently: We (L1) must
+ * autonomously send burst data based on our own clock, and every so
+ * often (currently every ~ 216 frames), we get a clock indication from
+ * the TRX.
+ *
+ * We're using a MONOTONIC timerfd interval timer for the 4.615ms frame
+ * intervals, and then compute + send the 8 bursts for that frame.
+ *
+ * Upon receiving a clock indication from the TRX, we compensate
+ * accordingly: If we were transmitting too fast, we're delaying the
+ * next interval timer accordingly. If we were too slow, we immediately
+ * send burst data for the missing frame numbers.
+ */
+
+/*! clock state of a given TRX */
+struct osmo_trx_clock_state {
+ /*! number of FN periods without TRX clock indication */
+ uint32_t fn_without_clock_ind;
+ struct {
+ /*! last FN we processed based on FN period timer */
+ uint32_t fn;
+ /*! time at which we last processed FN */
+ struct timespec tv;
+ } last_fn_timer;
+ struct {
+ /*! last FN we received a clock indication for */
+ uint32_t fn;
+ /*! time at which we received the last clock indication */
+ struct timespec tv;
+ } last_clk_ind;
+ /*! Osmocom FD wrapper for timerfd */
+ struct osmo_fd fn_timer_ofd;
+};
+
+/* gsm_bts->model_priv, specific to osmo-bts-trx */
+struct bts_trx_priv {
+ struct osmo_trx_clock_state clk_s;
+};
+
struct trx_config {
uint8_t trxd_hdr_ver_req; /* requested TRXD header version */
uint8_t trxd_hdr_ver_use; /* actual TRXD header version in use */
diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index b1fa207..cf40ea3 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -97,6 +97,10 @@
int bts_model_init(struct gsm_bts *bts)
{
+ struct bts_trx_priv *bts_trx = talloc_zero(bts, struct bts_trx_priv);
+ bts_trx->clk_s.fn_timer_ofd.fd = -1;
+
+ bts->model_priv = bts_trx;
bts->variant = BTS_OSMO_TRX;
bts->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2) | CIPHER_A5(3);
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 421cf16..ac34a11 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -1581,48 +1581,6 @@
return 0;
}
-/*
- * TRX frame clock handling
- *
- * In a "normal" synchronous PHY layer, we would be polled every time
- * the PHY needs data for a given frame number. However, the
- * OpenBTS-inherited TRX protocol works differently: We (L1) must
- * autonomously send burst data based on our own clock, and every so
- * often (currently every ~ 216 frames), we get a clock indication from
- * the TRX.
- *
- * We're using a MONOTONIC timerfd interval timer for the 4.615ms frame
- * intervals, and then compute + send the 8 bursts for that frame.
- *
- * Upon receiving a clock indication from the TRX, we compensate
- * accordingly: If we were transmitting too fast, we're delaying the
- * next interval timer accordingly. If we were too slow, we immediately
- * send burst data for the missing frame numbers.
- */
-
-/*! clock state of a given TRX */
-struct osmo_trx_clock_state {
- /*! number of FN periods without TRX clock indication */
- uint32_t fn_without_clock_ind;
- struct {
- /*! last FN we processed based on FN period timer */
- uint32_t fn;
- /*! time at which we last processed FN */
- struct timespec tv;
- } last_fn_timer;
- struct {
- /*! last FN we received a clock indication for */
- uint32_t fn;
- /*! time at which we received the last clock indication */
- struct timespec tv;
- } last_clk_ind;
- /*! Osmocom FD wrapper for timerfd */
- struct osmo_fd fn_timer_ofd;
-};
-
-/* TODO: This must go and become part of the phy_link */
-static struct osmo_trx_clock_state g_clk_s = { .fn_timer_ofd.fd = -1 };
-
/*! duration of a GSM frame in nano-seconds. (120ms/26) */
#define FRAME_DURATION_nS 4615384
/*! duration of a GSM frame in micro-seconds (120s/26) */
@@ -1666,7 +1624,8 @@
static int trx_fn_timer_cb(struct osmo_fd *ofd, unsigned int what)
{
struct gsm_bts *bts = ofd->data;
- struct osmo_trx_clock_state *tcs = &g_clk_s;
+ struct bts_trx_priv *bts_trx = (struct bts_trx_priv *)bts->model_priv;
+ struct osmo_trx_clock_state *tcs = &bts_trx->clk_s;
struct timespec tv_now;
uint64_t expire_count;
int64_t elapsed_us, error_us;
@@ -1749,7 +1708,8 @@
/*! called every time we receive a clock indication from TRX */
int trx_sched_clock(struct gsm_bts *bts, uint32_t fn)
{
- struct osmo_trx_clock_state *tcs = &g_clk_s;
+ struct bts_trx_priv *bts_trx = (struct bts_trx_priv *)bts->model_priv;
+ struct osmo_trx_clock_state *tcs = &bts_trx->clk_s;
struct timespec tv_now;
int elapsed_fn;
int64_t elapsed_us, elapsed_us_since_clk, elapsed_fn_since_clk, error_us_since_clk;
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/15614
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I9b7ffb51423ada74b8be347c57eade08f307f88f
Gerrit-Change-Number: 15614
Gerrit-PatchSet: 5
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191005/9736a44d/attachment.htm>