diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2022-07-29 04:50:36 +0700 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2022-07-29 20:35:19 +0700 |
commit | 72da0554e84b72e06c9a883f56fc1171a830aca1 (patch) | |
tree | ac5720c43bf3116184f85921295f0c7913075a41 | |
parent | f8822e476d35633089e70b6ab7286ca3984000e6 (diff) |
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
-rw-r--r-- | src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h | 9 | ||||
-rw-r--r-- | src/host/trxcon/src/trxcon.c | 28 | ||||
-rw-r--r-- | src/host/trxcon/src/trxcon_fsm.c | 33 |
3 files changed, 35 insertions, 35 deletions
diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h b/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h index 7b459ec5..69ac01eb 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 @@ struct trxcon_inst { /* 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 fe3d6638..35687d78 100644 --- a/src/host/trxcon/src/trxcon.c +++ b/src/host/trxcon/src/trxcon.c @@ -112,7 +112,7 @@ int l1sched_handle_config_req(struct l1sched_state *sched, 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 @@ int l1sched_handle_burst_req(struct l1sched_state *sched, { 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 @@ int l1sched_handle_data_cnf(struct l1sched_lchan_state *lchan, 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 @@ int l1sched_handle_data_cnf(struct l1sched_lchan_state *lchan, 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 @@ struct trxcon_inst *trxcon_inst_alloc(void *ctx, unsigned int id) 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 @@ void trxcon_inst_free(struct trxcon_inst *trxcon) 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 @@ static void l1ctl_conn_accept_cb(struct l1ctl_client *l1c) 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 @@ static void l1ctl_conn_close_cb(struct l1ctl_client *l1c) 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 0f06c29c..5329a92b 100644 --- a/src/host/trxcon/src/trxcon_fsm.c +++ b/src/host/trxcon/src/trxcon_fsm.c @@ -55,8 +55,8 @@ static void trxcon_allstate_action(struct osmo_fsm_inst *fi, 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 @@ static void trxcon_allstate_action(struct osmo_fsm_inst *fi, 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 @@ static int trxcon_timer_cb(struct osmo_fsm_inst *fi) 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 @@ static void trxcon_st_reset_action(struct osmo_fsm_inst *fi, 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 @@ static void trxcon_st_reset_action(struct osmo_fsm_inst *fi, 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 @@ static void trxcon_st_reset_action(struct osmo_fsm_inst *fi, 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 @@ static void trxcon_st_full_power_scan_action(struct osmo_fsm_inst *fi, { 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 @@ static void trxcon_st_fbsb_search_action(struct osmo_fsm_inst *fi, 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 @@ static void trxcon_st_bcch_ccch_action(struct osmo_fsm_inst *fi, 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 @@ static void trxcon_st_bcch_ccch_action(struct osmo_fsm_inst *fi, 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 @@ static void trxcon_st_bcch_ccch_action(struct osmo_fsm_inst *fi, /* 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 @@ static void trxcon_st_dedicated_action(struct osmo_fsm_inst *fi, /* 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; |