Change in osmo-bts[master]: nm_*fsm: Make FSMs aware of object being properly configured or not

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Wed Sep 22 12:23:52 UTC 2021


pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/25505 )

Change subject: nm_*fsm: Make FSMs aware of object being properly configured or not
......................................................................

nm_*fsm: Make FSMs aware of object being properly configured or not

This will allow in the future advertising children objects that the
parent object has been configured. It is useful for instance to let TRX
know that the BTS is configured.

Change-Id: Ie319465fd0e991bab8451ea34ec72ff3702533d2
---
M include/osmo-bts/nm_common_fsm.h
M include/osmo-bts/oml.h
M src/common/nm_bb_transc_fsm.c
M src/common/nm_bts_fsm.c
M src/common/nm_bts_sm_fsm.c
M src/common/nm_channel_fsm.c
M src/common/nm_common_fsm.c
M src/common/nm_radio_carrier_fsm.c
M src/osmo-bts-lc15/oml.c
M src/osmo-bts-oc2g/oml.c
M src/osmo-bts-octphy/l1_oml.c
M src/osmo-bts-omldummy/bts_model.c
M src/osmo-bts-sysmo/oml.c
M src/osmo-bts-trx/l1_if.c
M src/osmo-bts-virtual/bts_model.c
15 files changed, 263 insertions(+), 40 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, approved



diff --git a/include/osmo-bts/nm_common_fsm.h b/include/osmo-bts/nm_common_fsm.h
index 13d7e0c..1f0accc 100644
--- a/include/osmo-bts/nm_common_fsm.h
+++ b/include/osmo-bts/nm_common_fsm.h
@@ -25,10 +25,13 @@
 
 #include <osmocom/core/fsm.h>
 #include <osmocom/core/utils.h>
+#include <osmocom/core/msgb.h>
 
 /* Common */
 enum nm_fsm_events {
 	NM_EV_SW_ACT,
+	NM_EV_SETATTR_ACK, /* data: struct nm_fsm_ev_setattr_data */
+	NM_EV_SETATTR_NACK, /* data: struct nm_fsm_ev_setattr_data */
 	NM_EV_OPSTART_ACK,
 	NM_EV_OPSTART_NACK,
 	NM_EV_SHUTDOWN_START,
@@ -46,6 +49,11 @@
 };
 extern const struct value_string nm_fsm_event_names[];
 
+struct nm_fsm_ev_setattr_data {
+	struct msgb *msg; /* msgb ownership is transferred to FSM */
+	int cause;
+};
+
 
 /* BTS SiteManager */
 enum nm_bts_sm_op_fsm_states {
diff --git a/include/osmo-bts/oml.h b/include/osmo-bts/oml.h
index 42284f9..90c9077 100644
--- a/include/osmo-bts/oml.h
+++ b/include/osmo-bts/oml.h
@@ -32,6 +32,7 @@
 	struct gsm_bts *bts;
 	/* NM BTS Site Manager FSM */
 	struct osmo_fsm_inst *fi;
+	bool setattr_success;
 	bool opstart_success;
 };
 
diff --git a/src/common/nm_bb_transc_fsm.c b/src/common/nm_bb_transc_fsm.c
index 1b83cbd..40d5134 100644
--- a/src/common/nm_bb_transc_fsm.c
+++ b/src/common/nm_bb_transc_fsm.c
@@ -59,6 +59,7 @@
 static void st_op_disabled_notinstalled_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
 {
 	struct gsm_bts_bb_trx *bb_transc = (struct gsm_bts_bb_trx *)fi->priv;
+	bb_transc->mo.setattr_success = false;
 	bb_transc->mo.opstart_success = false;
 	oml_mo_state_chg(&bb_transc->mo, NM_OPSTATE_DISABLED, NM_AVSTATE_NOT_INSTALLED, NM_STATE_LOCKED);
 }
@@ -99,6 +100,7 @@
 	struct gsm_bts_trx *trx = gsm_bts_bb_trx_get_trx(bb_transc);
 	int i;
 
+	bb_transc->mo.setattr_success = false;
 	bb_transc->mo.opstart_success = false;
 	oml_mo_state_chg(&bb_transc->mo, NM_OPSTATE_DISABLED, NM_AVSTATE_OFF_LINE, -1);
 
@@ -114,10 +116,17 @@
 {
 	struct gsm_bts_bb_trx *bb_transc = (struct gsm_bts_bb_trx *)fi->priv;
 	struct gsm_bts_trx *trx = gsm_bts_bb_trx_get_trx(bb_transc);
+	struct nm_fsm_ev_setattr_data *setattr_data;
 	bool phy_state_connected;
 	bool rsl_link_connected;
 
 	switch (event) {
+	case NM_EV_SETATTR_ACK:
+	case NM_EV_SETATTR_NACK:
+		setattr_data = (struct nm_fsm_ev_setattr_data *)data;
+		bb_transc->mo.setattr_success = setattr_data->cause == 0;
+		oml_fom_ack_nack(setattr_data->msg, setattr_data->cause);
+		break;
 	case NM_EV_OPSTART_ACK:
 		bb_transc->mo.opstart_success = true;
 		oml_mo_opstart_ack(&bb_transc->mo);
@@ -150,6 +159,7 @@
 		rsl_link_connected = true;
 	}
 
+	/* We so far don't expect any SetAttributes for this NM object */
 	if (rsl_link_connected && phy_state_connected &&
 	    bb_transc->mo.opstart_success) {
 		nm_bb_transc_fsm_state_chg(fi, NM_BBTRANSC_ST_OP_ENABLED);
@@ -232,6 +242,8 @@
 	},
 	[NM_BBTRANSC_ST_OP_DISABLED_OFFLINE] = {
 		.in_event_mask =
+			X(NM_EV_SETATTR_ACK) |
+			X(NM_EV_SETATTR_NACK) |
 			X(NM_EV_OPSTART_ACK) |
 			X(NM_EV_OPSTART_NACK) |
 			X(NM_EV_RSL_UP) |
diff --git a/src/common/nm_bts_fsm.c b/src/common/nm_bts_fsm.c
index 9210e7a..54737bf 100644
--- a/src/common/nm_bts_fsm.c
+++ b/src/common/nm_bts_fsm.c
@@ -57,6 +57,7 @@
 static void st_op_disabled_notinstalled_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
 {
 	struct gsm_bts *bts = (struct gsm_bts *)fi->priv;
+	bts->mo.setattr_success = false;
 	bts->mo.opstart_success = false;
 	oml_mo_state_chg(&bts->mo, NM_OPSTATE_DISABLED, NM_AVSTATE_NOT_INSTALLED, NM_STATE_LOCKED);
 }
@@ -78,6 +79,7 @@
 static void st_op_disabled_offline_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
 {
 	struct gsm_bts *bts = (struct gsm_bts *)fi->priv;
+	bts->mo.setattr_success = false;
 	bts->mo.opstart_success = false;
 	oml_mo_state_chg(&bts->mo, NM_OPSTATE_DISABLED, NM_AVSTATE_OFF_LINE, -1);
 }
@@ -85,8 +87,15 @@
 static void st_op_disabled_offline(struct osmo_fsm_inst *fi, uint32_t event, void *data)
 {
 	struct gsm_bts *bts = (struct gsm_bts *)fi->priv;
+	struct nm_fsm_ev_setattr_data *setattr_data;
 
 	switch (event) {
+	case NM_EV_SETATTR_ACK:
+	case NM_EV_SETATTR_NACK:
+		setattr_data = (struct nm_fsm_ev_setattr_data *)data;
+		bts->mo.setattr_success = setattr_data->cause == 0;
+		oml_fom_ack_nack(setattr_data->msg, setattr_data->cause);
+		break;
 	case NM_EV_OPSTART_ACK:
 		bts->mo.opstart_success = true;
 		oml_mo_opstart_ack(&bts->mo);
@@ -146,6 +155,8 @@
 	},
 	[NM_BTS_ST_OP_DISABLED_OFFLINE] = {
 		.in_event_mask =
+			X(NM_EV_SETATTR_ACK) |
+			X(NM_EV_SETATTR_NACK) |
 			X(NM_EV_OPSTART_ACK) |
 			X(NM_EV_OPSTART_NACK),
 		.out_state_mask =
diff --git a/src/common/nm_bts_sm_fsm.c b/src/common/nm_bts_sm_fsm.c
index 267341e..2d43315 100644
--- a/src/common/nm_bts_sm_fsm.c
+++ b/src/common/nm_bts_sm_fsm.c
@@ -55,6 +55,7 @@
 static void st_op_disabled_notinstalled_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
 {
 	struct gsm_bts_sm *site_mgr = (struct gsm_bts_sm *)fi->priv;
+	site_mgr->mo.setattr_success = false;
 	site_mgr->mo.opstart_success = false;
 	oml_mo_state_chg(&site_mgr->mo, NM_OPSTATE_DISABLED, NM_AVSTATE_NOT_INSTALLED, NM_STATE_LOCKED);
 }
@@ -76,6 +77,7 @@
 static void st_op_disabled_offline_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
 {
 	struct gsm_bts_sm *site_mgr = (struct gsm_bts_sm *)fi->priv;
+	site_mgr->mo.setattr_success = false;
 	site_mgr->mo.opstart_success = false;
 	oml_mo_state_chg(&site_mgr->mo, NM_OPSTATE_DISABLED, NM_AVSTATE_OFF_LINE, -1);
 }
@@ -83,8 +85,15 @@
 static void st_op_disabled_offline(struct osmo_fsm_inst *fi, uint32_t event, void *data)
 {
 	struct gsm_bts_sm *site_mgr = (struct gsm_bts_sm *)fi->priv;
+	struct nm_fsm_ev_setattr_data *setattr_data;
 
 	switch (event) {
+	case NM_EV_SETATTR_ACK:
+	case NM_EV_SETATTR_NACK:
+		setattr_data = (struct nm_fsm_ev_setattr_data *)data;
+		site_mgr->mo.setattr_success = setattr_data->cause == 0;
+		oml_fom_ack_nack(setattr_data->msg, setattr_data->cause);
+		break;
 	case NM_EV_OPSTART_ACK:
 		site_mgr->mo.opstart_success = true;
 		oml_mo_opstart_ack(&site_mgr->mo);
@@ -144,6 +153,8 @@
 	},
 	[NM_BTS_SM_ST_OP_DISABLED_OFFLINE] = {
 		.in_event_mask =
+			X(NM_EV_SETATTR_ACK) |
+			X(NM_EV_SETATTR_NACK) |
 			X(NM_EV_OPSTART_ACK) |
 			X(NM_EV_OPSTART_NACK),
 		.out_state_mask =
diff --git a/src/common/nm_channel_fsm.c b/src/common/nm_channel_fsm.c
index e6c296f..f933a16 100644
--- a/src/common/nm_channel_fsm.c
+++ b/src/common/nm_channel_fsm.c
@@ -55,6 +55,7 @@
 static void st_op_disabled_notinstalled_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
 {
 	struct gsm_bts_trx_ts *ts = (struct gsm_bts_trx_ts *)fi->priv;
+	ts->mo.setattr_success = false;
 	ts->mo.opstart_success = false;
 	oml_mo_state_chg(&ts->mo, NM_OPSTATE_DISABLED, NM_AVSTATE_NOT_INSTALLED, NM_STATE_LOCKED);
 }
@@ -86,8 +87,15 @@
 static void st_op_disabled_dependency(struct osmo_fsm_inst *fi, uint32_t event, void *data)
 {
 	struct gsm_bts_trx_ts *ts = (struct gsm_bts_trx_ts *)fi->priv;
+	struct nm_fsm_ev_setattr_data *setattr_data;
 
 	switch (event) {
+	case NM_EV_SETATTR_ACK:
+	case NM_EV_SETATTR_NACK:
+		setattr_data = (struct nm_fsm_ev_setattr_data *)data;
+		ts->mo.setattr_success = setattr_data->cause == 0;
+		oml_fom_ack_nack(setattr_data->msg, setattr_data->cause);
+		break;
 	case NM_EV_OPSTART_ACK:
 		 LOGPFSML(fi, LOGL_NOTICE, "BSC trying to activate TS while still in avail=dependency. "
 			  "Allowing it to stay backward-compatible with older osmo-bts versions, but BSC is wrong.\n");
@@ -123,8 +131,15 @@
 static void st_op_disabled_offline(struct osmo_fsm_inst *fi, uint32_t event, void *data)
 {
 	struct gsm_bts_trx_ts *ts = (struct gsm_bts_trx_ts *)fi->priv;
+	struct nm_fsm_ev_setattr_data *setattr_data;
 
 	switch (event) {
+	case NM_EV_SETATTR_ACK:
+	case NM_EV_SETATTR_NACK:
+		setattr_data = (struct nm_fsm_ev_setattr_data *)data;
+		ts->mo.setattr_success = setattr_data->cause == 0;
+		oml_fom_ack_nack(setattr_data->msg, setattr_data->cause);
+		break;
 	case NM_EV_OPSTART_ACK:
 		ts->mo.opstart_success = true;
 		oml_mo_opstart_ack(&ts->mo);
@@ -199,6 +214,8 @@
 	},
 	[NM_CHAN_ST_OP_DISABLED_DEPENDENCY] = {
 		.in_event_mask =
+			X(NM_EV_SETATTR_ACK) |
+			X(NM_EV_SETATTR_NACK) |
 			X(NM_EV_OPSTART_ACK) |  /* backward compatibility, buggy BSC */
 			X(NM_EV_OPSTART_NACK) |
 			X(NM_EV_BBTRANSC_ENABLED) |
@@ -215,6 +232,8 @@
 	},
 	[NM_CHAN_ST_OP_DISABLED_OFFLINE] = {
 		.in_event_mask =
+			X(NM_EV_SETATTR_ACK) |
+			X(NM_EV_SETATTR_NACK) |
 			X(NM_EV_OPSTART_ACK) |
 			X(NM_EV_OPSTART_NACK) |
 			X(NM_EV_BBTRANSC_DISABLED) |
diff --git a/src/common/nm_common_fsm.c b/src/common/nm_common_fsm.c
index 2182fef..be11bef 100644
--- a/src/common/nm_common_fsm.c
+++ b/src/common/nm_common_fsm.c
@@ -25,6 +25,8 @@
 
 const struct value_string nm_fsm_event_names[] = {
 	{ NM_EV_SW_ACT, "SW_ACT" },
+	{ NM_EV_SETATTR_ACK, "SETATTR_ACK" },
+	{ NM_EV_SETATTR_NACK, "SETATTR_NACK" },
 	{ NM_EV_OPSTART_ACK, "OPSTART_ACK" },
 	{ NM_EV_OPSTART_NACK, "OPSTART_NACK" },
 	{ NM_EV_SHUTDOWN_START, "SHUTDOWN_START" },
diff --git a/src/common/nm_radio_carrier_fsm.c b/src/common/nm_radio_carrier_fsm.c
index 839632c..be03d1d 100644
--- a/src/common/nm_radio_carrier_fsm.c
+++ b/src/common/nm_radio_carrier_fsm.c
@@ -48,6 +48,7 @@
 static void st_op_disabled_notinstalled_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
 {
 	struct gsm_bts_trx *trx = (struct gsm_bts_trx *)fi->priv;
+	trx->mo.setattr_success = false;
 	trx->mo.opstart_success = false;
 	oml_mo_state_chg(&trx->mo, NM_OPSTATE_DISABLED, NM_AVSTATE_NOT_INSTALLED, NM_STATE_LOCKED);
 }
@@ -81,6 +82,7 @@
 	struct gsm_bts_trx *trx = (struct gsm_bts_trx *)fi->priv;
 	unsigned int i;
 
+	trx->mo.setattr_success = false;
 	trx->mo.opstart_success = false;
 	oml_mo_state_chg(&trx->mo, NM_OPSTATE_DISABLED, NM_AVSTATE_OFF_LINE, -1);
 
@@ -95,10 +97,17 @@
 static void st_op_disabled_offline(struct osmo_fsm_inst *fi, uint32_t event, void *data)
 {
 	struct gsm_bts_trx *trx = (struct gsm_bts_trx *)fi->priv;
+	struct nm_fsm_ev_setattr_data *setattr_data;
 	bool phy_state_connected;
 	bool rsl_link_connected;
 
 	switch (event) {
+	case NM_EV_SETATTR_ACK:
+	case NM_EV_SETATTR_NACK:
+		setattr_data = (struct nm_fsm_ev_setattr_data *)data;
+		trx->mo.setattr_success = setattr_data->cause == 0;
+		oml_fom_ack_nack(setattr_data->msg, setattr_data->cause);
+		break;
 	case NM_EV_OPSTART_ACK:
 		trx->mo.opstart_success = true;
 		oml_mo_opstart_ack(&trx->mo);
@@ -131,12 +140,13 @@
 	}
 
 	if (rsl_link_connected && phy_state_connected &&
-	    trx->mo.opstart_success) {
+	    trx->mo.setattr_success && trx->mo.opstart_success) {
 		nm_rcarrier_fsm_state_chg(fi, NM_RCARRIER_ST_OP_ENABLED);
 	} else {
-		LOGPFSML(fi, LOGL_INFO, "Delay switch to operative state Enabled, wait for:%s%s%s\n",
+		LOGPFSML(fi, LOGL_INFO, "Delay switch to operative state Enabled, wait for:%s%s%s%s\n",
 			 rsl_link_connected ? "" : " rsl",
 			 phy_state_connected ? "" : " phy",
+			 trx->mo.setattr_success ? "" : " setattr",
 			 trx->mo.opstart_success ? "" : " opstart");
 
 	}
@@ -206,6 +216,8 @@
 	},
 	[NM_RCARRIER_ST_OP_DISABLED_OFFLINE] = {
 		.in_event_mask =
+			X(NM_EV_SETATTR_ACK) |
+			X(NM_EV_SETATTR_NACK) |
 			X(NM_EV_OPSTART_ACK) |
 			X(NM_EV_OPSTART_NACK) |
 			X(NM_EV_RSL_UP) |
diff --git a/src/osmo-bts-lc15/oml.c b/src/osmo-bts-lc15/oml.c
index 9d0d99a..6169ef7 100644
--- a/src/osmo-bts-lc15/oml.c
+++ b/src/osmo-bts-lc15/oml.c
@@ -1834,11 +1834,31 @@
 int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg,
 			struct tlv_parsed *new_attr, int kind, void *obj)
 {
-	if (kind == NM_OC_RADIO_CARRIER) {
-		struct gsm_bts_trx *trx = obj;
-		struct lc15l1_hdl *fl1h = trx_lc15l1_hdl(trx);
+	struct abis_om_fom_hdr *foh = msgb_l3(msg);
+	struct gsm_abis_mo *mo = gsm_objclass2mo(bts, foh->obj_class, &foh->obj_inst);
+	struct nm_fsm_ev_setattr_data ev_data = {
+		.msg = msg,
+		.cause = 0,
+	};
+	int rc;
+	struct gsm_bts_trx *trx;
+	struct lc15l1_hdl *fl1h;
+	uint8_t cell_size;
+
+	/* TODO: NM Object without FSM: */
+	switch (foh->obj_class) {
+	case NM_OC_GPRS_NSE:
+	case NM_OC_GPRS_CELL:
+	case NM_OC_GPRS_NSVC:
+		return oml_fom_ack_nack(ev_data.msg, ev_data.cause);
+	}
+
+	switch (foh->msg_type) {
+	case NM_MT_SET_RADIO_ATTR:
+		trx = obj;
+		fl1h = trx_lc15l1_hdl(trx);
 		/* convert max TA to max cell size in qbits */
-		uint8_t cell_size = bts->max_ta << 2;
+		cell_size = bts->max_ta << 2;
 
 #if LITECELL15_API_VERSION >= LITECELL15_API(2,1,7)
 		/* We do not need to check for L1 handle
@@ -1870,9 +1890,14 @@
 			}
 #endif
 		}
+		break;
 	}
-	/* FIXME: we actually need to send a ACK or NACK for the OML message */
-	return oml_fom_ack_nack(msg, 0);
+
+	rc = osmo_fsm_inst_dispatch(mo->fi,
+				    ev_data.cause == 0 ? NM_EV_SETATTR_ACK : NM_EV_SETATTR_NACK,
+				    &ev_data);
+	/* msgb ownership is transferred to FSM if it received ev: */
+	return rc == 0 ? 1 : 0;
 }
 
 /* callback from OML */
diff --git a/src/osmo-bts-oc2g/oml.c b/src/osmo-bts-oc2g/oml.c
index b50e151..ba85f36 100644
--- a/src/osmo-bts-oc2g/oml.c
+++ b/src/osmo-bts-oc2g/oml.c
@@ -1843,11 +1843,31 @@
 int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg,
 			struct tlv_parsed *new_attr, int kind, void *obj)
 {
-	if (kind == NM_OC_RADIO_CARRIER) {
-		struct gsm_bts_trx *trx = obj;
-		struct oc2gl1_hdl *fl1h = trx_oc2gl1_hdl(trx);
+	struct abis_om_fom_hdr *foh = msgb_l3(msg);
+	struct gsm_abis_mo *mo = gsm_objclass2mo(bts, foh->obj_class, &foh->obj_inst);
+	struct nm_fsm_ev_setattr_data ev_data = {
+		.msg = msg,
+		.cause = 0,
+	};
+	int rc;
+	struct gsm_bts_trx *trx;
+	struct oc2gl1_hdl *fl1h;
+	uint8_t cell_size;
+
+	/* TODO: NM Object without FSM: */
+	switch (foh->obj_class) {
+	case NM_OC_GPRS_NSE:
+	case NM_OC_GPRS_CELL:
+	case NM_OC_GPRS_NSVC:
+		return oml_fom_ack_nack(ev_data.msg, ev_data.cause);
+	}
+
+	switch (foh->msg_type) {
+	case NM_MT_SET_RADIO_ATTR:
+		trx = obj;
+		fl1h = trx_oc2gl1_hdl(trx);
 		/* convert max TA to max cell size in qbits */
-		uint8_t cell_size = bts->max_ta << 2;
+		cell_size = bts->max_ta << 2;
 
 		/* We do not need to check for L1 handle
 		 * because the max cell size parameter can receive before MphInit */
@@ -1876,11 +1896,14 @@
 				l1if_set_txpower_c0_idle_pwr_red(fl1h, fl1h->phy_inst->u.oc2g.tx_c0_idle_pwr_red);
 			}
 		}
-
+		break;
 	}
 
-	/* FIXME: we actually need to send a ACK or NACK for the OML message */
-	return oml_fom_ack_nack(msg, 0);
+	rc = osmo_fsm_inst_dispatch(mo->fi,
+				    ev_data.cause == 0 ? NM_EV_SETATTR_ACK : NM_EV_SETATTR_NACK,
+				    &ev_data);
+	/* msgb ownsership is transferred to FSM if it received ev: */
+	return rc == 0 ? 1 : 0;
 }
 
 /* callback from OML */
diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c
index 1830599..73ab9bd 100644
--- a/src/osmo-bts-octphy/l1_oml.c
+++ b/src/osmo-bts-octphy/l1_oml.c
@@ -1748,13 +1748,36 @@
 int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg,
 			struct tlv_parsed *new_attr, int kind, void *obj)
 {
-	if (kind == NM_OC_RADIO_CARRIER) {
-		struct gsm_bts_trx *trx = obj;
-		/*struct octphy_hdl *fl1h = trx_octphy_hdl(trx); */
+	struct abis_om_fom_hdr *foh = msgb_l3(msg);
+	struct gsm_abis_mo *mo = gsm_objclass2mo(bts, foh->obj_class, &foh->obj_inst);
+	struct nm_fsm_ev_setattr_data ev_data = {
+		.msg = msg,
+		.cause = 0,
+	};
+	int rc;
+	struct gsm_bts_trx *trx;
 
-		power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL);
+	/* TODO: NM Object without FSM: */
+	switch (foh->obj_class) {
+	case NM_OC_GPRS_NSE:
+	case NM_OC_GPRS_CELL:
+	case NM_OC_GPRS_NSVC:
+		return oml_fom_ack_nack(ev_data.msg, ev_data.cause);
 	}
-	return oml_fom_ack_nack(msg, 0);
+
+	switch (foh->msg_type) {
+	case NM_MT_SET_RADIO_ATTR:
+		trx = obj;
+		/*struct octphy_hdl *fl1h = trx_octphy_hdl(trx); */
+		power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL);
+		break;
+	}
+
+	rc = osmo_fsm_inst_dispatch(mo->fi,
+				    ev_data.cause == 0 ? NM_EV_SETATTR_ACK : NM_EV_SETATTR_NACK,
+				    &ev_data);
+	/* msgb ownsership is transferred to FSM if it received ev: */
+	return rc == 0 ? 1 : 0;
 }
 
 
diff --git a/src/osmo-bts-omldummy/bts_model.c b/src/osmo-bts-omldummy/bts_model.c
index 5bfcfca..f5d59a3 100644
--- a/src/osmo-bts-omldummy/bts_model.c
+++ b/src/osmo-bts-omldummy/bts_model.c
@@ -97,20 +97,38 @@
 			struct tlv_parsed *new_attr, int kind, void *obj)
 {
 	struct abis_om_fom_hdr *foh = msgb_l3(msg);
-	int cause = 0;
+	struct gsm_abis_mo *mo = gsm_objclass2mo(bts, foh->obj_class, &foh->obj_inst);
+	struct nm_fsm_ev_setattr_data ev_data = {
+		.msg = msg,
+		.cause = 0,
+	};
+	int rc;
+
+	/* TODO: NM Object without FSM: */
+	switch (foh->obj_class) {
+	case NM_OC_GPRS_NSE:
+	case NM_OC_GPRS_CELL:
+	case NM_OC_GPRS_NSVC:
+		return oml_fom_ack_nack(ev_data.msg, ev_data.cause);
+	}
 
 	switch (foh->msg_type) {
 	case NM_MT_SET_BTS_ATTR:
-		cause = vbts_set_bts(obj);
+		ev_data.cause =  vbts_set_bts(obj);
 		break;
 	case NM_MT_SET_RADIO_ATTR:
-		cause = vbts_set_trx(obj);
+		ev_data.cause = vbts_set_trx(obj);
 		break;
 	case NM_MT_SET_CHAN_ATTR:
-		cause = vbts_set_ts(obj);
+		ev_data.cause = vbts_set_ts(obj);
 		break;
 	}
-	return oml_fom_ack_nack(msg, cause);
+
+	rc = osmo_fsm_inst_dispatch(mo->fi,
+				    ev_data.cause == 0 ? NM_EV_SETATTR_ACK : NM_EV_SETATTR_NACK,
+				    &ev_data);
+	/* msgb ownsership is transferred to FSM if it received ev: */
+	return rc == 0 ? 1 : 0;
 }
 
 /* MO: TS 12.21 Managed Object */
diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c
index 194afcd..74af56b 100644
--- a/src/osmo-bts-sysmo/oml.c
+++ b/src/osmo-bts-sysmo/oml.c
@@ -1748,17 +1748,40 @@
 int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg,
 			struct tlv_parsed *new_attr, int kind, void *obj)
 {
-	if (kind == NM_OC_RADIO_CARRIER) {
-		struct gsm_bts_trx *trx = obj;
-		struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx);
+	struct abis_om_fom_hdr *foh = msgb_l3(msg);
+	struct gsm_abis_mo *mo = gsm_objclass2mo(bts, foh->obj_class, &foh->obj_inst);
+	struct nm_fsm_ev_setattr_data ev_data = {
+		.msg = msg,
+		.cause = 0,
+	};
+	int rc;
+	struct gsm_bts_trx *trx;
+	struct femtol1_hdl *fl1h;
+
+	/* TODO: NM Object without FSM: */
+	switch (foh->obj_class) {
+	case NM_OC_GPRS_NSE:
+	case NM_OC_GPRS_CELL:
+	case NM_OC_GPRS_NSVC:
+		return oml_fom_ack_nack(ev_data.msg, ev_data.cause);
+	}
+
+	switch (foh->msg_type) {
+	case NM_MT_SET_RADIO_ATTR:
+		trx = obj;
+		fl1h = trx_femtol1_hdl(trx);
 
 		/* Did we go through MphInit yet? If yes fire and forget */
 		if (fl1h->hLayer1)
 			power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL);
+		break;
 	}
 
-	/* FIXME: we actually need to send a ACK or NACK for the OML message */
-	return oml_fom_ack_nack(msg, 0);
+	rc = osmo_fsm_inst_dispatch(mo->fi,
+				    ev_data.cause == 0 ? NM_EV_SETATTR_ACK : NM_EV_SETATTR_NACK,
+				    &ev_data);
+	/* msgb ownsership is transferred to FSM if it received ev: */
+	return rc == 0 ? 1 : 0;
 }
 
 /* callback from OML */
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index 6b417f4..90adde2 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -555,21 +555,38 @@
 			struct tlv_parsed *new_attr, int kind, void *obj)
 {
 	struct abis_om_fom_hdr *foh = msgb_l3(msg);
-	int cause = 0;
+	struct gsm_abis_mo *mo = gsm_objclass2mo(bts, foh->obj_class, &foh->obj_inst);
+	struct nm_fsm_ev_setattr_data ev_data = {
+		.msg = msg,
+		.cause = 0,
+	};
+	int rc;
+
+	/* TODO: NM Object without FSM: */
+	switch (foh->obj_class) {
+	case NM_OC_GPRS_NSE:
+	case NM_OC_GPRS_CELL:
+	case NM_OC_GPRS_NSVC:
+		return oml_fom_ack_nack(ev_data.msg, ev_data.cause);
+	}
 
 	switch (foh->msg_type) {
 	case NM_MT_SET_BTS_ATTR:
-		cause = trx_set_bts(obj, new_attr);
+		ev_data.cause = trx_set_bts(obj, new_attr);
 		break;
 	case NM_MT_SET_RADIO_ATTR:
-		cause = trx_set_trx(obj);
+		ev_data.cause = trx_set_trx(obj);
 		break;
 	case NM_MT_SET_CHAN_ATTR:
-		cause = trx_set_ts(obj);
+		ev_data.cause = trx_set_ts(obj);
 		break;
 	}
 
-	return oml_fom_ack_nack(msg, cause);
+	rc = osmo_fsm_inst_dispatch(mo->fi,
+				    ev_data.cause == 0 ? NM_EV_SETATTR_ACK : NM_EV_SETATTR_NACK,
+				    &ev_data);
+	/* msgb ownsership is transferred to FSM if it received ev: */
+	return rc == 0 ? 1 : 0;
 }
 
 /* callback from OML */
diff --git a/src/osmo-bts-virtual/bts_model.c b/src/osmo-bts-virtual/bts_model.c
index 48e9400..8704056 100644
--- a/src/osmo-bts-virtual/bts_model.c
+++ b/src/osmo-bts-virtual/bts_model.c
@@ -110,20 +110,38 @@
 			struct tlv_parsed *new_attr, int kind, void *obj)
 {
 	struct abis_om_fom_hdr *foh = msgb_l3(msg);
-	int cause = 0;
+	struct gsm_abis_mo *mo = gsm_objclass2mo(bts, foh->obj_class, &foh->obj_inst);
+	struct nm_fsm_ev_setattr_data ev_data = {
+		.msg = msg,
+		.cause = 0,
+	};
+	int rc;
+
+	/* TODO: NM Object without FSM: */
+	switch (foh->obj_class) {
+	case NM_OC_GPRS_NSE:
+	case NM_OC_GPRS_CELL:
+	case NM_OC_GPRS_NSVC:
+		return oml_fom_ack_nack(ev_data.msg, ev_data.cause);
+	}
 
 	switch (foh->msg_type) {
 	case NM_MT_SET_BTS_ATTR:
-		cause = vbts_set_bts(obj);
+		ev_data.cause = vbts_set_bts(obj);
 		break;
 	case NM_MT_SET_RADIO_ATTR:
-		cause = vbts_set_trx(obj);
+		ev_data.cause = vbts_set_trx(obj);
 		break;
 	case NM_MT_SET_CHAN_ATTR:
-		cause = vbts_set_ts(obj);
+		ev_data.cause = vbts_set_ts(obj);
 		break;
 	}
-	return oml_fom_ack_nack(msg, cause);
+
+	rc = osmo_fsm_inst_dispatch(mo->fi,
+				    ev_data.cause == 0 ? NM_EV_SETATTR_ACK : NM_EV_SETATTR_NACK,
+				    &ev_data);
+	/* msgb ownsership is transferred to FSM if it received ev: */
+	return rc == 0 ? 1 : 0;
 }
 
 /* MO: TS 12.21 Managed Object */

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/25505
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Ie319465fd0e991bab8451ea34ec72ff3702533d2
Gerrit-Change-Number: 25505
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210922/8084d000/attachment.htm>


More information about the gerrit-log mailing list