aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-octphy/l1_oml.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-09-25 18:55:55 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2020-10-02 20:13:18 +0200
commit1290c52d2b1aa615597c833060a700e963aefca2 (patch)
tree89caba805ca6a3a4a94ea6bb8e43d8af76534ed7 /src/osmo-bts-octphy/l1_oml.c
parent135068d5c8ddb5fcca3379b94eb3f777b3a14525 (diff)
Introduce NM Radio Carrier and Baseband Transceiver FSMs
All the Operative State logic to manage a RadioCarrier//BBTransc NM objects is centralized in these FSM, where other parts of the code simply send events to it. This allows keeping state consistent and offloading logic from each bts backend, since they are only required to submit events now. The idea in the long run is to also replace other NM objects with similar FSMs. This improved logic fixes bug where PHY + RSL link became available before OPSTART and hence op state changed to Enabled before receiving any OPSTART message. Change-Id: Ifb249a821c4270918699b6375a72b3a618e8cfbe
Diffstat (limited to 'src/osmo-bts-octphy/l1_oml.c')
-rw-r--r--src/osmo-bts-octphy/l1_oml.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c
index 8156c49a..f036fe95 100644
--- a/src/osmo-bts-octphy/l1_oml.c
+++ b/src/osmo-bts-octphy/l1_oml.c
@@ -28,6 +28,7 @@
#include <osmocom/core/talloc.h>
#include <osmocom/core/utils.h>
+#include <osmocom/core/fsm.h>
#include <osmo-bts/gsm_data.h>
#include <osmo-bts/logging.h>
@@ -40,6 +41,8 @@
#include <osmo-bts/l1sap.h>
#include <osmo-bts/nm_bts_sm_fsm.h>
#include <osmo-bts/nm_bts_fsm.h>
+#include <osmo-bts/nm_radio_carrier_fsm.h>
+#include <osmo-bts/nm_bb_transc_fsm.h>
#include "l1_if.h"
#include "l1_oml.h"
@@ -188,22 +191,15 @@ extern uint8_t rach_detected_Other_g;
static int opstart_compl(struct gsm_abis_mo *mo)
{
struct gsm_bts_trx *trx = gsm_bts_trx_num(mo->bts, mo->obj_inst.trx_nr);
- uint8_t tn;
/* TODO: Send NACK in case of error! */
+ /* We already have a FSM for Radio Carrier, handle it there */
+ if (mo->obj_class == NM_OC_RADIO_CARRIER)
+ return osmo_fsm_inst_dispatch(trx->rc.fi, NM_RCARRIER_EV_OPSTART_ACK, NULL);
+
/* Set to Operational State: Enabled */
oml_mo_state_chg(mo, NM_OPSTATE_ENABLED, NM_AVSTATE_OK);
- if (mo->obj_class == NM_OC_RADIO_CARRIER) {
- /* Mark Dependency TS as Offline (ready to be Opstarted) */
- for (tn = 0; tn < TRX_NR_TS; tn++) {
- if (trx->ts[tn].mo.nm_state.operational == NM_OPSTATE_DISABLED &&
- trx->ts[tn].mo.nm_state.availability == NM_AVSTATE_DEPENDENCY) {
- oml_mo_state_chg(&trx->ts[tn].mo, NM_OPSTATE_DISABLED, NM_AVSTATE_OFF_LINE);
- }
- }
- }
-
/* hack to auto-activate all SAPIs for the BCCH/CCCH on TS0 */
if (mo->obj_class == NM_OC_CHANNEL && mo->obj_inst.trx_nr == 0 &&
mo->obj_inst.ts_nr == 7) {
@@ -1314,7 +1310,7 @@ static int trx_open_compl_cb(struct octphy_hdl *fl1h, struct msgb *resp, void *d
msgb_free(resp);
- opstart_compl(&trx->mo);
+ opstart_compl(&trx->rc.mo);
octphy_hw_get_pcb_info(fl1h);
octphy_hw_get_rf_port_info(fl1h, 0);
@@ -1447,12 +1443,13 @@ uint32_t trx_get_hlayer1(const struct gsm_bts_trx *trx)
static int trx_init(struct gsm_bts_trx *trx)
{
- if (!gsm_abis_mo_check_attr(&trx->mo, trx_rqd_attr,
+ if (!gsm_abis_mo_check_attr(&trx->rc.mo, trx_rqd_attr,
ARRAY_SIZE(trx_rqd_attr))) {
/* HACK: spec says we need to decline, but openbsc
* doesn't deal with this very well */
- return oml_mo_opstart_ack(&trx->mo);
- /* return oml_mo_opstart_nack(&trx->mo, NM_NACK_CANT_PERFORM); */
+ return osmo_fsm_inst_dispatch(trx->rc.fi, NM_RCARRIER_EV_OPSTART_ACK, NULL);
+ //return osmo_fsm_inst_dispatch(trx->rc.fi, NM_RCARRIER_EV_OPSTART_NACK,
+ // (void*)(intptr_t)NM_NACK_CANT_PERFORM);
}
l1if_check_app_version(trx);
@@ -1764,8 +1761,9 @@ int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg,
/* callback from OML */
int bts_model_opstart(struct gsm_bts *bts, struct gsm_abis_mo *mo, void *obj)
{
- int rc = -1;
+ struct gsm_bts_trx* trx;
struct gsm_bts_trx_ts *ts;
+ int rc;
switch (mo->obj_class) {
case NM_OC_SITE_MANAGER:
@@ -1775,13 +1773,17 @@ int bts_model_opstart(struct gsm_bts *bts, struct gsm_abis_mo *mo, void *obj)
rc = osmo_fsm_inst_dispatch(bts->nm.fi, NM_BTS_EV_OPSTART_ACK, NULL);
break;
case NM_OC_RADIO_CARRIER:
- rc = trx_init(obj);
+ trx = (struct gsm_bts_trx*) obj;
+ rc = trx_init(trx);
+ break;
+ case NM_OC_BASEB_TRANSC:
+ trx = (struct gsm_bts_trx *) obj;
+ rc = osmo_fsm_inst_dispatch(trx->bb_transc.fi, NM_BBTRANSC_EV_OPSTART_ACK, NULL);
break;
case NM_OC_CHANNEL:
ts = (struct gsm_bts_trx_ts*) obj;
rc = ts_connect_as(ts, ts->pchan, pchan_act_compl_cb, NULL);
break;
- case NM_OC_BASEB_TRANSC:
case NM_OC_GPRS_NSE:
case NM_OC_GPRS_CELL:
case NM_OC_GPRS_NSVC: