diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-09-27 17:21:31 +0200 |
---|---|---|
committer | pespin <pespin@sysmocom.de> | 2019-10-05 20:50:13 +0000 |
commit | ca574b19d3e0b3ca2f9532130693d446ae61ca04 (patch) | |
tree | c5fbabc9f26bd7dec1f713c801b8c4e9ff01f36d /src/osmo-bts-trx/trx_if.c | |
parent | 9e1f0e1a13678a1a31e681ce0995df95d1e2ea32 (diff) |
bts-trx: Get rid of messy transceiver_available state handler
This variable meaning has been changing its exact meaning over time
until finally not being really clear which kind of state it holds.
Initially it seemed to be used to identfy whether CLOCK IND were being
received. However, over time both osmo-bts and osmo-trx have evolved and
were fixed so that clock indications are only sent by osmo-trx after
POWERON command is sent. As a result, this state can be checked simply by
looking at the "powered" phy_link variable, which is only set to true
once the TRX has confirmed the POWERON command, and hence it is sending
CLOCK IND.
On the other hand, at some point in time "available" started to be set to 1
in bts_model_phy_link_open(), which means available is nowadays almost
always 1 from startup until the end (only dropped during bts_shutdown(),
when we are already exiting the process anyway).
As a result, !available condition in scheduler_trx.c:trx_fn_timer_cb can
almost never happen, because available is set to true already. Only
possibility would be if an old process of osmo-trx (not set up by this
BTS process) is still sending CLOCK INDs, but in that case we for sure
don't want to configure the BTS based on that, but ignore them until
this BTS process has again configured the TRX. So that whole check can
be dropped. We are better checking for "powered" state, which is far
more accurate, and we better do that in trx_if.c before calling
trx_fn_timer_cb().
Other uses of "transceiver_available" being used can be changed to use
plink->state!= PHY_LINK_SHUTDOWN, since available was already being set
to 1 at the same time the plink->state was being set to
PHY_LINK_CONNECTING.
As a result of this state handling re-arrangement, OS#4215 is fixed
since trx_if_powered() is used instead of previous state condition to
check whether data frames should be sent.
Related: OS#4215
Change-Id: I35f4697bd33dbe8a4c76c9500b82c16589c701d4
Diffstat (limited to 'src/osmo-bts-trx/trx_if.c')
-rw-r--r-- | src/osmo-bts-trx/trx_if.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c index a260919a..9933109b 100644 --- a/src/osmo-bts-trx/trx_if.c +++ b/src/osmo-bts-trx/trx_if.c @@ -48,8 +48,6 @@ #include "l1_if.h" #include "trx_if.h" -int transceiver_available = 0; - /* * socket helper functions */ @@ -125,6 +123,10 @@ static int trx_clk_read_cb(struct osmo_fd *ofd, unsigned int what) "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); @@ -201,13 +203,6 @@ static int trx_ctrl_cmd_cb(struct trx_l1h *l1h, int critical, void *cb, const ch va_list ap; int pending; - if (!transceiver_available && - !(!strcmp(cmd, "POWEROFF") || !strcmp(cmd, "POWERON"))) { - LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "CTRL %s ignored: No clock from " - "transceiver, please fix!\n", cmd); - return -EIO; - } - pending = !llist_empty(&l1h->trx_ctrl_list); /* create message */ @@ -1097,12 +1092,11 @@ int trx_if_send_burst(struct trx_l1h *l1h, uint8_t tn, uint32_t fn, uint8_t pwr, /* copy ubits {0,1} */ memcpy(buf + 6, bits, nbits); - /* we must be sure that we have clock, and we have sent all control - * data */ - if (transceiver_available && llist_empty(&l1h->trx_ctrl_list)) { + /* we must be sure that TRX is on */ + if (trx_if_powered(l1h)) { send(l1h->trx_ofd_data.fd, buf, nbits + 6, 0); } else - LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "Ignoring TX data, transceiver offline.\n"); + LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "Ignoring TX data, transceiver powered off.\n"); return 0; } @@ -1255,8 +1249,7 @@ int bts_model_phy_link_open(struct phy_link *plink) if (trx_phy_inst_open(pinst) < 0) goto cleanup; } - /* FIXME: is there better way to check/report TRX availability? */ - transceiver_available = 1; + return 0; cleanup: |