fixeria has submitted this change. (
https://gerrit.osmocom.org/c/osmocom-bb/+/43825?usp=email )
Change subject: trxcon/trx_if: refuse POWERON if Rx/Tx frequency is not set
......................................................................
trxcon/trx_if: refuse POWERON if Rx/Tx frequency is not set
Track the currently tuned Rx/Tx frequencies (or whether frequency
hopping is enabled instead), and refuse to power the transceiver on
if neither is the case. Both are reset on RESET and POWEROFF.
Change-Id: Ie570432cd6f28fe77d312f80ed53f248af0230c8
---
M src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h
M src/host/trxcon/src/trx_if.c
2 files changed, 46 insertions(+), 4 deletions(-)
Approvals:
osmith: Looks good to me, but someone else must approve
pespin: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h
b/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h
index 1b97e3e..907eb79 100644
--- a/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h
+++ b/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h
@@ -19,6 +19,11 @@
struct osmo_fsm_inst *fi;
uint32_t fn_advance;
+ /* Rx/Tx frequencies (in kHz) tuned via RXTUNE/TXTUNE */
+ uint32_t rx_freq_khz;
+ uint32_t tx_freq_khz;
+ bool hopping;
+
/* Some private data */
void *priv;
};
diff --git a/src/host/trxcon/src/trx_if.c b/src/host/trxcon/src/trx_if.c
index fcfa01c..fbc0fcd 100644
--- a/src/host/trxcon/src/trx_if.c
+++ b/src/host/trxcon/src/trx_if.c
@@ -205,6 +205,11 @@
static int trx_if_cmd_poweroff(struct trx_instance *trx)
{
+ /* The transceiver forgets the tuned Rx/Tx frequencies on POWEROFF */
+ trx->rx_freq_khz = 0;
+ trx->tx_freq_khz = 0;
+ trx->hopping = false;
+
return trx_ctrl_cmd(trx, 1, "POWEROFF", "");
}
@@ -261,6 +266,7 @@
const struct trxcon_phyif_cmdp_setfreq_h0 *cmdp)
{
uint16_t freq10;
+ int rc;
/* RX is downlink on MS side */
freq10 = gsm_arfcn2freq10(cmdp->band_arfcn, 0);
@@ -269,13 +275,19 @@
return -ENOTSUP;
}
- return trx_ctrl_cmd(trx, 1, "RXTUNE", "%u", freq10 * 100);
+ rc = trx_ctrl_cmd(trx, 1, "RXTUNE", "%u", freq10 * 100);
+ if (rc == 0) {
+ trx->rx_freq_khz = freq10 * 100;
+ trx->hopping = false;
+ }
+ return rc;
}
static int trx_if_cmd_txtune(struct trx_instance *trx,
const struct trxcon_phyif_cmdp_setfreq_h0 *cmdp)
{
uint16_t freq10;
+ int rc;
/* TX is uplink on MS side */
freq10 = gsm_arfcn2freq10(cmdp->band_arfcn, 1);
@@ -284,7 +296,12 @@
return -ENOTSUP;
}
- return trx_ctrl_cmd(trx, 1, "TXTUNE", "%u", freq10 * 100);
+ rc = trx_ctrl_cmd(trx, 1, "TXTUNE", "%u", freq10 * 100);
+ if (rc == 0) {
+ trx->tx_freq_khz = freq10 * 100;
+ trx->hopping = false;
+ }
+ return rc;
}
/*
@@ -419,7 +436,13 @@
/* Overwrite the last space */
*(ptr - 1) = '\0';
- return trx_ctrl_cmd(trx, 1, "SETFH", "%u %u %s", cmdp->hsn, cmdp->maio,
ma_buf);
+ rc = trx_ctrl_cmd(trx, 1, "SETFH", "%u %u %s", cmdp->hsn, cmdp->maio,
ma_buf);
+ if (rc == 0) {
+ trx->rx_freq_khz = 0;
+ trx->tx_freq_khz = 0;
+ trx->hopping = true;
+ }
+ return rc;
}
static void trx_fsm_allstate_action(struct osmo_fsm_inst *fi, uint32_t event,
void *data)
@@ -440,6 +463,20 @@
}
}
+/* No state change here: the POWERON response (see trx_ctrl_read_cb())
+ * is what moves us to TRX_ST_POWERON. */
+static void trx_fsm_handle_poweron_req(struct osmo_fsm_inst *fi)
+{
+ struct trx_instance *trx = fi->priv;
+
+ if (!trx->hopping && (trx->rx_freq_khz == 0 || trx->tx_freq_khz == 0)) {
+ LOGPFSML(fi, LOGL_ERROR, "Refusing POWERON: Rx/Tx frequency not
set\n");
+ return;
+ }
+
+ trx_if_cmd_poweron(trx);
+}
+
static void trx_fsm_poweroff_action(struct osmo_fsm_inst *fi, uint32_t event,
void *data)
{
struct trx_instance *trx = fi->priv;
@@ -447,7 +484,7 @@
switch (event) {
case TRXCON_PHYIF_CMDT_POWERON:
- trx_if_cmd_poweron(trx);
+ trx_fsm_handle_poweron_req(fi);
break;
case TRXCON_PHYIF_CMDT_SETFREQ_H0:
trx_if_cmd_rxtune(trx, &cmd->param.setfreq_h0);
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/43825?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Ie570432cd6f28fe77d312f80ed53f248af0230c8
Gerrit-Change-Number: 43825
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>