Timur Davydov has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/42693?usp=email )
Change subject: trx: factor out clock indication handling into helper ......................................................................
trx: factor out clock indication handling into helper
Extract clock indication handling logic into trx_clk_phy() and reuse it from trx_clk_read_cb()
This separates core FN processing from socket-specific code and prepares for alternative clock sources
No functional changes intended
Change-Id: I0e6b3e25da14ada4d0ef86fd4c4e6bbc12e447d2 --- M src/osmo-bts-trx/trx_if.c 1 file changed, 22 insertions(+), 14 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/93/42693/1
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c index 6445e9d..aabc54c 100644 --- a/src/osmo-bts-trx/trx_if.c +++ b/src/osmo-bts-trx/trx_if.c @@ -68,6 +68,27 @@ * TRX clock socket */
+/* sched clock for physical instance */ +static int trx_clk_phy(struct phy_link *plink, struct phy_instance *pinst, unsigned fn) +{ + LOGPPHI(pinst, DTRX, LOGL_INFO, "Clock indication: fn=%u\n", fn); + + if (fn >= GSM_TDMA_HYPERFRAME) { + fn %= GSM_TDMA_HYPERFRAME; + LOGPPHI(pinst, DTRX, LOGL_ERROR, "Indicated clock's FN is not " + "wrapping correctly, correcting to fn=%u\n", fn); + } + + if (!plink->u.osmotrx.powered) { + LOGPPHI(pinst, DTRX, LOGL_NOTICE, "Ignoring CLOCK IND %u, TRX not yet powered on\n", fn); + return 0; + } + /* inform core TRX clock handling code that a FN has been received */ + trx_sched_clock(pinst->trx->bts, fn); + + return 0; +} + /* get clock from clock socket */ static void trx_clk_read_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) { @@ -100,20 +121,7 @@ goto ret_free_msg; }
- LOGPPHI(pinst, DTRX, LOGL_INFO, "Clock indication: fn=%u\n", fn); - - if (fn >= GSM_TDMA_HYPERFRAME) { - fn %= GSM_TDMA_HYPERFRAME; - LOGPPHI(pinst, DTRX, LOGL_ERROR, "Indicated clock's FN is not " - "wrapping correctly, correcting to fn=%u\n", fn); - } - - if (!plink->u.osmotrx.powered) { - LOGPPHI(pinst, DTRX, LOGL_NOTICE, "Ignoring CLOCK IND %u, TRX not yet powered on\n", fn); - goto ret_free_msg; - } - /* inform core TRX clock handling code that a FN has been received */ - trx_sched_clock(pinst->trx->bts, fn); + trx_clk_phy(plink, pinst, fn);
ret_free_msg: msgb_free(msg);