diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-09-27 16:44:14 +0200 |
---|---|---|
committer | pespin <pespin@sysmocom.de> | 2019-10-05 20:50:13 +0000 |
commit | accbf5bc732462a1564371dcbbde2f0dc5c23544 (patch) | |
tree | fe1d3e66e27d653996a39b4f4b79a31e19eeff71 /src/osmo-bts-trx/l1_if.h | |
parent | 972c24314694396c9b66fd8175cdcd40f01bdd39 (diff) |
bts-trx: Allocate struct osmo_trx_clock_state as part of bts-trx private data
Related: OS#4215
Change-Id: I9b7ffb51423ada74b8be347c57eade08f307f88f
Diffstat (limited to 'src/osmo-bts-trx/l1_if.h')
-rw-r--r-- | src/osmo-bts-trx/l1_if.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h index 87df951b..29bd2468 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 */ |