fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/28835 )
Change subject: trxcon: abstract out 'struct trxcon_inst' from L1CTL/TRXC/TRXD ......................................................................
trxcon: abstract out 'struct trxcon_inst' from L1CTL/TRXC/TRXD
This allows replacing L1CTL and/or TRXC/TRXD with something else.
Change-Id: I7282da6dd16216bb4295c4d18f993251defbdf0a Related: OS#5599 --- M src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h M src/host/trxcon/src/trxcon.c M src/host/trxcon/src/trxcon_fsm.c 3 files changed, 35 insertions(+), 35 deletions(-)
Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve
diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h b/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h index 7b459ec..69ac01e 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h @@ -1,8 +1,6 @@ #pragma once
struct l1sched_state; -struct trx_instance; -struct l1ctl_client;
extern struct osmo_fsm trxcon_fsm_def;
@@ -136,9 +134,10 @@
/* The L1 scheduler */ struct l1sched_state *sched; - /* L1/L2 interfaces */ - struct trx_instance *trx; - struct l1ctl_client *l1c; + /* PHY interface (e.g. TRXC/TRXD) */ + void *phyif; + /* L2 interface (e.g. L1CTL) */ + void *l2if;
/* L1 parameters */ struct { diff --git a/src/host/trxcon/src/trxcon.c b/src/host/trxcon/src/trxcon.c index fe3d663..35687d7 100644 --- a/src/host/trxcon/src/trxcon.c +++ b/src/host/trxcon/src/trxcon.c @@ -112,7 +112,7 @@
switch (cr->type) { case L1SCHED_CFG_PCHAN_COMB: - return trx_if_cmd_setslot(trxcon->trx, + return trx_if_cmd_setslot(trxcon->phyif, cr->pchan_comb.tn, cr->pchan_comb.pchan); default: @@ -127,7 +127,7 @@ { struct trxcon_inst *trxcon = sched->priv;
- return trx_if_tx_burst(trxcon->trx, br); + return trx_if_tx_burst(trxcon->phyif, br); }
/* External L2 API for the scheduler */ @@ -211,12 +211,12 @@ switch (dt) { case L1SCHED_DT_TRAFFIC: case L1SCHED_DT_PACKET_DATA: - rc = l1ctl_tx_dt_conf(trxcon->l1c, &dl_hdr, true); + rc = l1ctl_tx_dt_conf(trxcon->l2if, &dl_hdr, true); data_len = lchan->prim->payload_len; data = lchan->prim->payload; break; case L1SCHED_DT_SIGNALING: - rc = l1ctl_tx_dt_conf(trxcon->l1c, &dl_hdr, false); + rc = l1ctl_tx_dt_conf(trxcon->l2if, &dl_hdr, false); data_len = lchan->prim->payload_len; data = lchan->prim->payload; break; @@ -226,7 +226,7 @@
rach = (struct l1sched_ts_prim_rach *)lchan->prim->payload;
- rc = l1ctl_tx_rach_conf(trxcon->l1c, trxcon->l1p.band_arfcn, fn); + rc = l1ctl_tx_rach_conf(trxcon->l2if, trxcon->l1p.band_arfcn, fn); if (lchan->prim->type == L1SCHED_PRIM_RACH11) { ra_buf[0] = (uint8_t)(rach->ra >> 3); ra_buf[1] = (uint8_t)(rach->ra & 0x07); @@ -271,11 +271,11 @@ trxcon->log_prefix = talloc_asprintf(trxcon, "%s: ", osmo_fsm_inst_name(trxcon->fi));
/* Init transceiver interface */ - trxcon->trx = trx_if_open(trxcon, + trxcon->phyif = trx_if_open(trxcon, app_data.trx_bind_ip, app_data.trx_remote_ip, app_data.trx_base_port); - if (trxcon->trx == NULL) { + if (trxcon->phyif == NULL) { trxcon_inst_free(trxcon); return NULL; } @@ -301,10 +301,10 @@ if (trxcon->sched != NULL) l1sched_free(trxcon->sched); /* Close active connections */ - if (trxcon->l1c != NULL) - l1ctl_client_conn_close(trxcon->l1c); - if (trxcon->trx != NULL) - trx_if_close(trxcon->trx); + if (trxcon->l2if != NULL) + l1ctl_client_conn_close(trxcon->l2if); + if (trxcon->phyif != NULL) + trx_if_close(trxcon->phyif);
if (trxcon->fi != NULL) osmo_fsm_inst_free(trxcon->fi); @@ -323,7 +323,7 @@
l1c->log_prefix = talloc_strdup(l1c, trxcon->log_prefix); l1c->priv = trxcon; - trxcon->l1c = l1c; + trxcon->l2if = l1c; }
static void l1ctl_conn_close_cb(struct l1ctl_client *l1c) @@ -335,8 +335,8 @@
osmo_fsm_inst_dispatch(trxcon->fi, TRXCON_EV_L2IF_FAILURE, NULL);
- /* l1c is free()ed by the caller */ - trxcon->l1c = NULL; + /* l2if is free()ed by the caller */ + trxcon->l2if = NULL; trxcon_inst_free(trxcon); }
diff --git a/src/host/trxcon/src/trxcon_fsm.c b/src/host/trxcon/src/trxcon_fsm.c index 0f06c29..5329a92 100644 --- a/src/host/trxcon/src/trxcon_fsm.c +++ b/src/host/trxcon/src/trxcon_fsm.c @@ -55,8 +55,8 @@ 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->trx); - trx_if_cmd_echo(trxcon->trx); + trx_if_cmd_poweroff(trxcon->phyif); + trx_if_cmd_echo(trxcon->phyif); break; case TRXCON_EV_RESET_SCHED_REQ: l1sched_reset(trxcon->sched, false); @@ -66,7 +66,7 @@ const struct trxcon_param_set_config_req *req = data;
if (trxcon->l1p.ta != req->timing_advance) - trx_if_cmd_setta(trxcon->trx, req->timing_advance); + trx_if_cmd_setta(trxcon->phyif, req->timing_advance); trxcon->l1p.tx_power = req->tx_power; trxcon->l1p.ta = req->timing_advance; break; @@ -82,7 +82,7 @@
switch (fi->state) { case TRXCON_ST_FBSB_SEARCH: - l1ctl_tx_fbsb_fail(trxcon->l1c, trxcon->l1p.band_arfcn); + l1ctl_tx_fbsb_fail(trxcon->l2if, trxcon->l1p.band_arfcn); osmo_fsm_inst_state_chg(fi, TRXCON_ST_RESET, 0, 0); return 0; default: @@ -99,6 +99,7 @@ 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);
@@ -110,14 +111,14 @@ trxcon->l1p.band_arfcn = req->band_arfcn;
/* Tune transceiver to required ARFCN */ - trx_if_cmd_rxtune(trxcon->trx, req->band_arfcn); - trx_if_cmd_txtune(trxcon->trx, req->band_arfcn); + trx_if_cmd_rxtune(trxcon->phyif, req->band_arfcn); + trx_if_cmd_txtune(trxcon->phyif, req->band_arfcn); }
/* Transceiver might have been powered on before, e.g. * in case of sending L1CTL_FBSB_REQ due to signal loss. */ - if (!trxcon->trx->powered_up) - trx_if_cmd_poweron(trxcon->trx); + if (!trx->powered_up) + trx_if_cmd_poweron(trxcon->phyif); break; } case TRXCON_EV_FULL_POWER_SCAN_REQ: @@ -125,7 +126,7 @@ const struct trxcon_param_full_power_scan_req *req = data;
osmo_fsm_inst_state_chg(fi, TRXCON_ST_FULL_POWER_SCAN, 0, 0); /* TODO: timeout */ - trx_if_cmd_measure(trxcon->trx, req->band_arfcn_start, req->band_arfcn_stop); + trx_if_cmd_measure(trxcon->phyif, req->band_arfcn_start, req->band_arfcn_stop); break; } default: @@ -143,7 +144,7 @@ { const struct trxcon_param_full_power_scan_res *res = data;
- l1ctl_tx_pm_conf(trxcon->l1c, res->band_arfcn, res->dbm, res->last_result); + l1ctl_tx_pm_conf(trxcon->l2if, res->band_arfcn, res->dbm, res->last_result); break; } default: @@ -159,7 +160,7 @@ switch (event) { case TRXCON_EV_FBSB_SEARCH_RES: osmo_fsm_inst_state_chg(fi, TRXCON_ST_BCCH_CCCH, 0, 0); - l1ctl_tx_fbsb_conf(trxcon->l1c, + l1ctl_tx_fbsb_conf(trxcon->l2if, trxcon->l1p.band_arfcn, trxcon->sched->bsic); break; @@ -231,7 +232,7 @@
if (req->hopping) { /* Apply the freq. hopping parameters */ - rc = trx_if_cmd_setfh(trxcon->trx, + rc = trx_if_cmd_setfh(trxcon->phyif, req->h1.hsn, req->h1.maio, &req->h1.ma[0], req->h1.n); if (rc) @@ -241,9 +242,9 @@ trxcon->l1p.band_arfcn = 0xffff; } else { /* Tune transceiver to required ARFCN */ - if (trx_if_cmd_rxtune(trxcon->trx, req->h0.band_arfcn)) + if (trx_if_cmd_rxtune(trxcon->phyif, req->h0.band_arfcn)) return; - if (trx_if_cmd_txtune(trxcon->trx, req->h0.band_arfcn)) + if (trx_if_cmd_txtune(trxcon->phyif, req->h0.band_arfcn)) return;
/* Update current ARFCN */ @@ -282,7 +283,7 @@ /* TODO: set proper .snr */ };
- l1ctl_tx_dt_ind(trxcon->l1c, &dl_hdr, ind->data, ind->data_len, false); + l1ctl_tx_dt_ind(trxcon->l2if, &dl_hdr, ind->data, ind->data_len, false); break; } default: @@ -377,7 +378,7 @@ /* TODO: set proper .snr */ };
- l1ctl_tx_dt_ind(trxcon->l1c, &dl_hdr, + l1ctl_tx_dt_ind(trxcon->l2if, &dl_hdr, ind->data, ind->data_len, event == TRXCON_EV_RX_TRAFFIC_IND); break;