fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/29868 )
Change subject: trxcon: implement an abstract PHYIF API ......................................................................
trxcon: implement an abstract PHYIF API
Change-Id: I3d7c717cfc3616809d22efb1903abbf843594258 --- M src/host/trxcon/include/osmocom/bb/trxcon/Makefile.am A src/host/trxcon/include/osmocom/bb/trxcon/phyif.h M src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h M src/host/trxcon/src/trx_if.c M src/host/trxcon/src/trxcon.c M src/host/trxcon/src/trxcon_fsm.c 6 files changed, 298 insertions(+), 113 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/68/29868/1
diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/Makefile.am b/src/host/trxcon/include/osmocom/bb/trxcon/Makefile.am index 8636c93..c80721c 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/Makefile.am +++ b/src/host/trxcon/include/osmocom/bb/trxcon/Makefile.am @@ -3,6 +3,7 @@ l1ctl_server.h \ l1ctl.h \ sched_utils.h \ + phyif.h \ trx_if.h \ logging.h \ trxcon.h \ diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/phyif.h b/src/host/trxcon/include/osmocom/bb/trxcon/phyif.h new file mode 100644 index 0000000..8a8d859 --- /dev/null +++ b/src/host/trxcon/include/osmocom/bb/trxcon/phyif.h @@ -0,0 +1,83 @@ +#pragma once + +#include <stdint.h> + +#include <osmocom/core/bits.h> + +/* PHYIF command type */ +enum phyif_cmd_type { + PHYIF_CMDT_RESET, + PHYIF_CMDT_POWERON, + PHYIF_CMDT_POWEROFF, + PHYIF_CMDT_MEASURE, + PHYIF_CMDT_SETFREQ_H0, + PHYIF_CMDT_SETFREQ_H1, + PHYIF_CMDT_SETSLOT, + PHYIF_CMDT_SETTA, +}; + +/* param of PHYIF_CMDT_SETFREQ_H0 */ +struct phyif_cmdp_setfreq_h0 { + uint16_t band_arfcn; +}; + +/* param of PHYIF_CMDT_SETFREQ_H1 */ +struct phyif_cmdp_setfreq_h1 { + uint8_t hsn; + uint8_t maio; + const uint16_t *ma; + unsigned int ma_len; +}; + +/* param of PHYIF_CMDT_SETSLOT */ +struct phyif_cmdp_setslot { + uint8_t tn; + uint8_t pchan; /* enum gsm_phys_chan_config */ +}; + +/* param of PHYIF_CMDT_SETTA */ +struct phyif_cmdp_setta { + int8_t ta; /* intentionally signed */ +}; + +/* param of PHYIF_CMDT_MEASURE */ +struct phyif_cmdp_measure { + uint16_t band_arfcn_start; + uint16_t band_arfcn_stop; +}; + +struct phyif_cmd { + enum phyif_cmd_type type; + union { + struct phyif_cmdp_setfreq_h0 setfreq_h0; + struct phyif_cmdp_setfreq_h1 setfreq_h1; + struct phyif_cmdp_setslot setslot; + struct phyif_cmdp_setta setta; + struct phyif_cmdp_measure measure; + } param; +}; + +/* BURST.req - a burst to be transmitted */ +struct phyif_burst_req { + uint32_t fn; + uint8_t tn; + uint8_t pwr; + const ubit_t *burst; + unsigned int burst_len; +}; + +/* BURST.ind - a received burst */ +struct phyif_burst_ind { + uint32_t fn; + uint8_t tn; + int16_t toa256; + int8_t rssi; + sbit_t burst[148]; + unsigned int burst_len; +}; + + +int phyif_handle_burst_ind(void *phyif, const struct phyif_burst_ind *bi); +int phyif_handle_burst_req(void *phyif, const struct phyif_burst_req *br); +int phyif_handle_cmd(void *phyif, const struct phyif_cmd *cmd); +void phyif_close(void *phyif); 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 1faa610..9628f72 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h @@ -5,13 +5,12 @@ #include <osmocom/core/timer.h> #include <osmocom/core/fsm.h>
-#include <osmocom/gsm/gsm_utils.h> +#include <osmocom/bb/trxcon/phyif.h>
#define TRXC_BUF_SIZE 1024 #define TRXD_BUF_SIZE 512
/* Forward declaration to avoid mutual include */ -struct l1sched_burst_req; struct trxcon_inst;
enum trx_fsm_states { @@ -51,25 +50,7 @@
struct trx_instance *trx_if_open(struct trxcon_inst *trxcon, const char *local_host, const char *remote_host, uint16_t port); -void trx_if_flush_ctrl(struct trx_instance *trx); void trx_if_close(struct trx_instance *trx);
-int trx_if_cmd_poweron(struct trx_instance *trx); -int trx_if_cmd_poweroff(struct trx_instance *trx); -int trx_if_cmd_echo(struct trx_instance *trx); - -int trx_if_cmd_setta(struct trx_instance *trx, int8_t ta); - -int trx_if_cmd_rxtune(struct trx_instance *trx, uint16_t band_arfcn); -int trx_if_cmd_txtune(struct trx_instance *trx, uint16_t band_arfcn); - -int trx_if_cmd_setslot(struct trx_instance *trx, uint8_t tn, - enum gsm_phys_chan_config pchan); -int trx_if_cmd_setfh(struct trx_instance *trx, uint8_t hsn, uint8_t maio, - const uint16_t *ma, size_t ma_len); - -int trx_if_cmd_measure(struct trx_instance *trx, - uint16_t band_arfcn_start, uint16_t band_arfcn_stop); - -int trx_if_tx_burst(struct trx_instance *trx, - const struct l1sched_burst_req *br); +int trx_if_handle_phyif_burst_req(struct trx_instance *trx, const struct phyif_burst_req *br); +int trx_if_handle_phyif_cmd(struct trx_instance *trx, const struct phyif_cmd *cmd); diff --git a/src/host/trxcon/src/trx_if.c b/src/host/trxcon/src/trx_if.c index 6f225ee..b746161 100644 --- a/src/host/trxcon/src/trx_if.c +++ b/src/host/trxcon/src/trx_if.c @@ -4,6 +4,7 @@ * * Copyright (C) 2013 by Andreas Eversberg jolly@eversberg.eu * Copyright (C) 2016-2017 by Vadim Yanitskiy axilirator@gmail.com + * Copyright (C) 2022 by sysmocom - s.f.m.c. GmbH info@sysmocom.de * * All Rights Reserved * @@ -39,7 +40,6 @@
#include <osmocom/gsm/gsm_utils.h>
-#include <osmocom/bb/l1sched/l1sched.h> #include <osmocom/bb/trxcon/trxcon.h> #include <osmocom/bb/trxcon/trx_if.h> #include <osmocom/bb/trxcon/logging.h> @@ -247,17 +247,17 @@ * RSP POWERON <status> */
-int trx_if_cmd_echo(struct trx_instance *trx) +static int trx_if_cmd_echo(struct trx_instance *trx) { return trx_ctrl_cmd(trx, 1, "ECHO", ""); }
-int trx_if_cmd_poweroff(struct trx_instance *trx) +static int trx_if_cmd_poweroff(struct trx_instance *trx) { return trx_ctrl_cmd(trx, 1, "POWEROFF", ""); }
-int trx_if_cmd_poweron(struct trx_instance *trx) +static int trx_if_cmd_poweron(struct trx_instance *trx) { if (trx->powered_up) { /* FIXME: this should be handled by the FSM, not here! */ @@ -278,8 +278,8 @@ * RSP SETSLOT <status> <timeslot> <chantype> */
-int trx_if_cmd_setslot(struct trx_instance *trx, uint8_t tn, - enum gsm_phys_chan_config pchan) +static int trx_if_cmd_setslot(struct trx_instance *trx, + const struct phyif_cmdp_setslot *cmdp) { /* Values correspond to 'enum ChannelCombination' in osmo-trx.git */ static const uint8_t chan_types[_GSM_PCHAN_MAX] = { @@ -295,7 +295,8 @@ [GSM_PCHAN_PDCH] = 13, };
- return trx_ctrl_cmd(trx, 1, "SETSLOT", "%u %u", tn, chan_types[pchan]); + return trx_ctrl_cmd(trx, 1, "SETSLOT", "%u %u", + cmdp->tn, chan_types[cmdp->pchan]); }
/* @@ -310,28 +311,30 @@ * RSP (RX/TX)TUNE <status> <kHz> */
-int trx_if_cmd_rxtune(struct trx_instance *trx, uint16_t band_arfcn) +static int trx_if_cmd_rxtune(struct trx_instance *trx, + const struct phyif_cmdp_setfreq_h0 *cmdp) { uint16_t freq10;
/* RX is downlink on MS side */ - freq10 = gsm_arfcn2freq10(band_arfcn, 0); + freq10 = gsm_arfcn2freq10(cmdp->band_arfcn, 0); if (freq10 == 0xffff) { - LOGPFSML(trx->fi, LOGL_ERROR, "ARFCN %d not defined\n", band_arfcn); + LOGPFSML(trx->fi, LOGL_ERROR, "ARFCN %d not defined\n", cmdp->band_arfcn); return -ENOTSUP; }
return trx_ctrl_cmd(trx, 1, "RXTUNE", "%u", freq10 * 100); }
-int trx_if_cmd_txtune(struct trx_instance *trx, uint16_t band_arfcn) +static int trx_if_cmd_txtune(struct trx_instance *trx, + const struct phyif_cmdp_setfreq_h0 *cmdp) { uint16_t freq10;
/* TX is uplink on MS side */ - freq10 = gsm_arfcn2freq10(band_arfcn, 1); + freq10 = gsm_arfcn2freq10(cmdp->band_arfcn, 1); if (freq10 == 0xffff) { - LOGPFSML(trx->fi, LOGL_ERROR, "ARFCN %d not defined\n", band_arfcn); + LOGPFSML(trx->fi, LOGL_ERROR, "ARFCN %d not defined\n", cmdp->band_arfcn); return -ENOTSUP; }
@@ -350,19 +353,20 @@ * RSP MEASURE <status> <kHz> <dB> */
-int trx_if_cmd_measure(struct trx_instance *trx, - uint16_t band_arfcn_start, uint16_t band_arfcn_stop) +static int trx_if_cmd_measure(struct trx_instance *trx, + const struct phyif_cmdp_measure *cmdp) { uint16_t freq10;
/* Update ARFCN range for measurement */ - trx->pm_band_arfcn_start = band_arfcn_start; - trx->pm_band_arfcn_stop = band_arfcn_stop; + trx->pm_band_arfcn_start = cmdp->band_arfcn_start; + trx->pm_band_arfcn_stop = cmdp->band_arfcn_stop;
/* Calculate a frequency for current ARFCN (DL) */ - freq10 = gsm_arfcn2freq10(band_arfcn_start, 0); + freq10 = gsm_arfcn2freq10(cmdp->band_arfcn_start, 0); if (freq10 == 0xffff) { - LOGPFSML(trx->fi, LOGL_ERROR, "ARFCN %d not defined\n", band_arfcn_start); + LOGPFSML(trx->fi, LOGL_ERROR, + "ARFCN %d not defined\n", cmdp->band_arfcn_start); return -ENOTSUP; }
@@ -399,8 +403,14 @@ osmo_fsm_inst_dispatch(trxcon->fi, TRXCON_EV_FULL_POWER_SCAN_RES, &res);
/* Schedule a next measurement */ - if (band_arfcn != trx->pm_band_arfcn_stop) - trx_if_cmd_measure(trx, ++band_arfcn, trx->pm_band_arfcn_stop); + if (band_arfcn != trx->pm_band_arfcn_stop) { + const struct phyif_cmdp_measure cmdp = { + .band_arfcn_start = ++band_arfcn, + .band_arfcn_stop = trx->pm_band_arfcn_stop, + }; + + trx_if_cmd_measure(trx, &cmdp); + } }
/* @@ -416,9 +426,10 @@ * RSP SETTA <status> <TA> */
-int trx_if_cmd_setta(struct trx_instance *trx, int8_t ta) +static int trx_if_cmd_setta(struct trx_instance *trx, + const struct phyif_cmdp_setta *cmdp) { - return trx_ctrl_cmd(trx, 0, "SETTA", "%d", ta); + return trx_ctrl_cmd(trx, 0, "SETTA", "%d", cmdp->ta); }
/* @@ -434,8 +445,8 @@ * channel list is expected to be sorted in ascending order. */
-int trx_if_cmd_setfh(struct trx_instance *trx, uint8_t hsn, uint8_t maio, - const uint16_t *ma, size_t ma_len) +static int trx_if_cmd_setfh(struct trx_instance *trx, + const struct phyif_cmdp_setfreq_h1 *cmdp) { /* Reserve some room for CMD SETFH <HSN> <MAIO> */ char ma_buf[TRXC_BUF_SIZE - 24]; @@ -445,20 +456,20 @@ int i, rc;
/* Make sure that Mobile Allocation has at least one ARFCN */ - if (!ma_len || ma == NULL) { + if (!cmdp->ma_len || cmdp->ma == NULL) { LOGPFSML(trx->fi, LOGL_ERROR, "Mobile Allocation is empty?!?\n"); return -EINVAL; }
/* Compose a sequence of Rx/Tx frequencies (mobile allocation) */ - for (i = 0, ptr = ma_buf; i < ma_len; i++) { + for (i = 0, ptr = ma_buf; i < cmdp->ma_len; i++) { /* Convert ARFCN to a pair of Rx/Tx frequencies (Hz * 10) */ - rx_freq = gsm_arfcn2freq10(ma[i], 0); /* Rx: Downlink */ - tx_freq = gsm_arfcn2freq10(ma[i], 1); /* Tx: Uplink */ + rx_freq = gsm_arfcn2freq10(cmdp->ma[i], 0); /* Rx: Downlink */ + tx_freq = gsm_arfcn2freq10(cmdp->ma[i], 1); /* Tx: Uplink */ if (rx_freq == 0xffff || tx_freq == 0xffff) { LOGPFSML(trx->fi, LOGL_ERROR, "Failed to convert ARFCN %u " "to a pair of Rx/Tx frequencies\n", - ma[i] & ~ARFCN_FLAG_MASK); + cmdp->ma[i] & ~ARFCN_FLAG_MASK); return -EINVAL; }
@@ -466,7 +477,7 @@ rc = snprintf(ptr, ma_buf_len, "%u %u ", rx_freq * 100, tx_freq * 100); if (rc < 0 || rc > ma_buf_len) { /* Prevent buffer overflow */ LOGPFSML(trx->fi, LOGL_ERROR, "Not enough room to encode " - "Mobile Allocation (N=%zu)\n", ma_len); + "Mobile Allocation (N=%zu)\n", cmdp->ma_len); return -ENOSPC; }
@@ -478,7 +489,7 @@ /* Overwrite the last space */ *(ptr - 1) = '\0';
- return trx_ctrl_cmd(trx, 1, "SETFH", "%u %u %s", hsn, maio, ma_buf); + return trx_ctrl_cmd(trx, 1, "SETFH", "%u %u %s", cmdp->hsn, cmdp->maio, ma_buf); }
/* Get response from CTRL socket */ @@ -569,6 +580,49 @@ return -EIO; }
+int trx_if_handle_phyif_cmd(struct trx_instance *trx, const struct phyif_cmd *cmd) +{ + int rc; + + switch (cmd->type) { + case PHYIF_CMDT_RESET: + if ((rc = trx_if_cmd_poweroff(trx)) != 0) + return rc; + rc = trx_if_cmd_echo(trx); + break; + case PHYIF_CMDT_POWERON: + rc = trx_if_cmd_poweron(trx); + break; + case PHYIF_CMDT_POWEROFF: + rc = trx_if_cmd_poweroff(trx); + break; + case PHYIF_CMDT_MEASURE: + rc = trx_if_cmd_measure(trx, &cmd->param.measure); + break; + case PHYIF_CMDT_SETFREQ_H0: + if ((rc = trx_if_cmd_rxtune(trx, &cmd->param.setfreq_h0)) != 0) + return rc; + if ((rc = trx_if_cmd_txtune(trx, &cmd->param.setfreq_h0)) != 0) + return rc; + break; + case PHYIF_CMDT_SETFREQ_H1: + rc = trx_if_cmd_setfh(trx, &cmd->param.setfreq_h1); + break; + case PHYIF_CMDT_SETSLOT: + rc = trx_if_cmd_setslot(trx, &cmd->param.setslot); + break; + case PHYIF_CMDT_SETTA: + rc = trx_if_cmd_setta(trx, &cmd->param.setta); + break; + default: + LOGPFSML(trx->fi, LOGL_ERROR, + "Unhandled PHYIF command type=0x%02x\n", cmd->type); + rc = -ENODEV; + } + + return rc; +} + /* ------------------------------------------------------------------------ */ /* Data interface handlers */ /* ------------------------------------------------------------------------ */ @@ -594,13 +648,8 @@ static int trx_data_rx_cb(struct osmo_fd *ofd, unsigned int what) { struct trx_instance *trx = ofd->data; - struct trxcon_inst *trxcon = trx->trxcon; - struct l1sched_meas_set meas; + struct phyif_burst_ind bi; uint8_t buf[TRXD_BUF_SIZE]; - sbit_t bits[148]; - int8_t rssi, tn; - int16_t toa256; - uint32_t fn; ssize_t read_len;
read_len = read(ofd->fd, buf, sizeof(buf)); @@ -615,52 +664,41 @@ return -EINVAL; }
- tn = buf[0]; - fn = osmo_load32be(buf + 1); - rssi = -(int8_t) buf[5]; - toa256 = ((int16_t) (buf[6] << 8) | buf[7]); + bi = (struct phyif_burst_ind) { + .tn = buf[0], + .fn = osmo_load32be(buf + 1), + .rssi = -(int8_t) buf[5], + .toa256 = (int16_t) (buf[6] << 8) | buf[7], + .burst_len = 148, + };
/* Copy and convert bits {254..0} to sbits {-127..127} */ for (unsigned int i = 0; i < 148; i++) { if (buf[8 + i] == 255) - bits[i] = -127; + bi.burst[i] = -127; else - bits[i] = 127 - buf[8 + i]; + bi.burst[i] = 127 - buf[8 + i]; }
- if (tn >= 8) { - LOGPFSMSL(trx->fi, DTRXD, LOGL_ERROR, "Illegal TS %d\n", tn); + if (bi.tn >= 8) { + LOGPFSMSL(trx->fi, DTRXD, LOGL_ERROR, "Illegal TS %d\n", bi.tn); return -EINVAL; }
- if (fn >= 2715648) { - LOGPFSMSL(trx->fi, DTRXD, LOGL_ERROR, "Illegal FN %u\n", fn); + if (bi.fn >= 2715648) { + LOGPFSMSL(trx->fi, DTRXD, LOGL_ERROR, "Illegal FN %u\n", bi.fn); return -EINVAL; }
LOGPFSMSL(trx->fi, DTRXD, LOGL_DEBUG, "RX burst tn=%u fn=%u rssi=%d toa=%d\n", - tn, fn, rssi, toa256); + bi.tn, bi.fn, bi.rssi, bi.toa256);
- /* Group the measurements together */ - meas = (struct l1sched_meas_set) { - .toa256 = toa256, - .rssi = rssi, - .fn = fn, - }; - - /* Poke scheduler */ - l1sched_handle_rx_burst(trxcon->sched, tn, fn, bits, 148, &meas); - - /* Correct local clock counter */ - if (fn % 51 == 0) - l1sched_clck_handle(trxcon->sched, fn); - - return 0; + return phyif_handle_burst_ind(trx, &bi); }
-int trx_if_tx_burst(struct trx_instance *trx, - const struct l1sched_burst_req *br) +int trx_if_handle_phyif_burst_req(struct trx_instance *trx, + const struct phyif_burst_req *br) { uint8_t buf[TRXD_BUF_SIZE]; size_t length; @@ -760,7 +798,7 @@ }
/* Flush pending control messages */ -void trx_if_flush_ctrl(struct trx_instance *trx) +static void trx_if_flush_ctrl(struct trx_instance *trx) { struct trx_ctrl_msg *tcm;
diff --git a/src/host/trxcon/src/trxcon.c b/src/host/trxcon/src/trxcon.c index d46cd8e..0329d0b 100644 --- a/src/host/trxcon/src/trxcon.c +++ b/src/host/trxcon/src/trxcon.c @@ -42,6 +42,7 @@ #include <osmocom/gsm/gsm_utils.h>
#include <osmocom/bb/trxcon/trxcon.h> +#include <osmocom/bb/trxcon/phyif.h> #include <osmocom/bb/trxcon/trx_if.h> #include <osmocom/bb/trxcon/logging.h> #include <osmocom/bb/trxcon/l1ctl.h> @@ -134,8 +135,52 @@ const struct l1sched_burst_req *br) { struct trxcon_inst *trxcon = sched->priv; + const struct phyif_burst_req phybr = { + .fn = br->fn, + .tn = br->tn, + .pwr = br->pwr, + .burst = &br->burst[0], + .burst_len = br->burst_len, + };
- return trx_if_tx_burst(trxcon->phyif, br); + return phyif_handle_burst_req(trxcon->phyif, &phybr); +} + +/* External L1 API for the PHYIF */ +int phyif_handle_burst_ind(void *phyif, const struct phyif_burst_ind *bi) +{ + struct trx_instance *trx = phyif; + struct trxcon_inst *trxcon = trx->trxcon; + const struct l1sched_meas_set meas = { + .fn = bi->fn, + .toa256 = bi->toa256, + .rssi = bi->rssi, + }; + + /* Poke scheduler */ + l1sched_handle_rx_burst(trxcon->sched, bi->tn, bi->fn, + &bi->burst[0], bi->burst_len, &meas); + + /* Correct local clock counter */ + if (bi->fn % 51 == 0) + l1sched_clck_handle(trxcon->sched, bi->fn); + + return 0; +} + +int phyif_handle_burst_req(void *phyif, const struct phyif_burst_req *br) +{ + return trx_if_handle_phyif_burst_req(phyif, br); +} + +int phyif_handle_cmd(void *phyif, const struct phyif_cmd *cmd) +{ + return trx_if_handle_phyif_cmd(phyif, cmd); +} + +void phyif_close(void *phyif) +{ + trx_if_close(phyif); }
/* External L2 API for the scheduler */ diff --git a/src/host/trxcon/src/trxcon_fsm.c b/src/host/trxcon/src/trxcon_fsm.c index 0d03740..38343b5 100644 --- a/src/host/trxcon/src/trxcon_fsm.c +++ b/src/host/trxcon/src/trxcon_fsm.c @@ -30,7 +30,7 @@ #include <osmocom/core/talloc.h>
#include <osmocom/bb/trxcon/trxcon.h> -#include <osmocom/bb/trxcon/trx_if.h> +#include <osmocom/bb/trxcon/phyif.h> #include <osmocom/bb/trxcon/logging.h> #include <osmocom/bb/trxcon/l1ctl.h> #include <osmocom/bb/trxcon/l1ctl_server.h> @@ -44,6 +44,7 @@ uint32_t event, void *data) { struct trxcon_inst *trxcon = fi->priv; + struct phyif_cmd phycmd = { };
switch (event) { case TRXCON_EV_PHYIF_FAILURE: @@ -58,8 +59,9 @@ if (fi->state != TRXCON_ST_RESET) osmo_fsm_inst_state_chg(fi, TRXCON_ST_RESET, 0, 0); l1sched_reset(trxcon->sched, true); - trx_if_cmd_poweroff(trxcon->phyif); - trx_if_cmd_echo(trxcon->phyif); + + phycmd.type = PHYIF_CMDT_RESET; + phyif_handle_cmd(trxcon->phyif, &phycmd); break; case TRXCON_EV_RESET_SCHED_REQ: l1sched_reset(trxcon->sched, false); @@ -70,13 +72,17 @@
switch (req->type) { case TRXCON_PHY_CFGT_PCHAN_COMB: - trx_if_cmd_setslot(trxcon->phyif, - req->pchan_comb.tn, - req->pchan_comb.pchan); + phycmd.type = PHYIF_CMDT_SETSLOT; + phycmd.param.setslot.tn = req->pchan_comb.tn; + phycmd.param.setslot.pchan = req->pchan_comb.pchan; + phyif_handle_cmd(trxcon->phyif, &phycmd); break; case TRXCON_PHY_CFGT_TX_PARAMS: - if (trxcon->l1p.ta != req->tx_params.timing_advance) - trx_if_cmd_setta(trxcon->phyif, req->tx_params.timing_advance); + if (trxcon->l1p.ta != req->tx_params.timing_advance) { + phycmd.type = PHYIF_CMDT_SETTA; + phycmd.param.setta.ta = req->tx_params.timing_advance; + phyif_handle_cmd(trxcon->phyif, &phycmd); + } trxcon->l1p.tx_power = req->tx_params.tx_power; trxcon->l1p.ta = req->tx_params.timing_advance; break; @@ -127,7 +133,6 @@ case TRXCON_EV_FBSB_SEARCH_REQ: { const struct trxcon_param_fbsb_search_req *req = data; - const struct trx_instance *trx = trxcon->phyif;
osmo_fsm_inst_state_chg_ms(fi, TRXCON_ST_FBSB_SEARCH, req->timeout_ms, 0);
@@ -135,26 +140,39 @@
/* Only if current ARFCN differs */ if (trxcon->l1p.band_arfcn != req->band_arfcn) { + const struct phyif_cmd phycmd = { + .type = PHYIF_CMDT_SETFREQ_H0, + .param.setfreq_h0 = { + .band_arfcn = req->band_arfcn, + }, + }; + /* Update current ARFCN */ trxcon->l1p.band_arfcn = req->band_arfcn;
/* Tune transceiver to required ARFCN */ - trx_if_cmd_rxtune(trxcon->phyif, req->band_arfcn); - trx_if_cmd_txtune(trxcon->phyif, req->band_arfcn); + phyif_handle_cmd(trxcon->phyif, &phycmd); }
/* Transceiver might have been powered on before, e.g. * in case of sending L1CTL_FBSB_REQ due to signal loss. */ - if (!trx->powered_up) - trx_if_cmd_poweron(trxcon->phyif); + const struct phyif_cmd phycmd = { .type = PHYIF_CMDT_POWERON }; + phyif_handle_cmd(trxcon->phyif, &phycmd); break; } case TRXCON_EV_FULL_POWER_SCAN_REQ: { const struct trxcon_param_full_power_scan_req *req = data; + const struct phyif_cmd phycmd = { + .type = PHYIF_CMDT_MEASURE, + .param.measure = { + .band_arfcn_start = req->band_arfcn_start, + .band_arfcn_stop = req->band_arfcn_stop, + }, + };
osmo_fsm_inst_state_chg(fi, TRXCON_ST_FULL_POWER_SCAN, 0, 0); /* TODO: timeout */ - trx_if_cmd_measure(trxcon->phyif, req->band_arfcn_start, req->band_arfcn_stop); + phyif_handle_cmd(trxcon->phyif, &phycmd); break; } default: @@ -178,8 +196,15 @@ case TRXCON_EV_FULL_POWER_SCAN_REQ: { const struct trxcon_param_full_power_scan_req *req = data; + const struct phyif_cmd phycmd = { + .type = PHYIF_CMDT_MEASURE, + .param.measure = { + .band_arfcn_start = req->band_arfcn_start, + .band_arfcn_stop = req->band_arfcn_stop, + }, + };
- trx_if_cmd_measure(trxcon->phyif, req->band_arfcn_start, req->band_arfcn_stop); + phyif_handle_cmd(trxcon->phyif, &phycmd); break; } default: @@ -266,20 +291,32 @@ }
if (req->hopping) { + const struct phyif_cmd phycmd = { + .type = PHYIF_CMDT_SETFREQ_H1, + .param.setfreq_h1 = { + .hsn = req->h1.hsn, + .maio = req->h1.maio, + .ma = &req->h1.ma[0], + .ma_len = req->h1.n, + }, + }; + /* Apply the freq. hopping parameters */ - rc = trx_if_cmd_setfh(trxcon->phyif, - req->h1.hsn, req->h1.maio, - &req->h1.ma[0], req->h1.n); - if (rc) + if (phyif_handle_cmd(trxcon->phyif, &phycmd) != 0) return;
/* Set current ARFCN to an invalid value */ trxcon->l1p.band_arfcn = 0xffff; } else { + const struct phyif_cmd phycmd = { + .type = PHYIF_CMDT_SETFREQ_H0, + .param.setfreq_h0 = { + .band_arfcn = req->h0.band_arfcn, + }, + }; + /* Tune transceiver to required ARFCN */ - if (trx_if_cmd_rxtune(trxcon->phyif, req->h0.band_arfcn)) - return; - if (trx_if_cmd_txtune(trxcon->phyif, req->h0.band_arfcn)) + if (phyif_handle_cmd(trxcon->phyif, &phycmd) != 0) return;
/* Update current ARFCN */ @@ -495,7 +532,7 @@ l1ctl_client_conn_close(trxcon->l2if); } if (trxcon->phyif != NULL) - trx_if_close(trxcon->phyif); + phyif_close(trxcon->phyif);
talloc_free(trxcon); fi->priv = NULL;