[PATCH] osmocom-bb[master]: mobile: Directly inform the primitive layer about an event

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/.

Holger Freyther gerrit-no-reply at lists.osmocom.org
Mon Nov 27 15:21:30 UTC 2017


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/4931

to look at the new patch set (#3).

mobile: Directly inform the primitive layer about an event

Forward started/shutdown changes to the primitive layer which will
turn them into indications. The other option might be to use the
signals but it seems primitives are a superset of the signals.

The notify will be done per MS and then the right primitive
instance will be searched and the indication be sent. The approach
will be applied to other systems as well.

The signal framework might be seen as
a subset of the primitives A signal mostly being a different form
of an indication.

Change-Id: I5df20a4ab79c06b515780675b6df2929aa976f0d
---
M src/host/layer23/include/osmocom/bb/mobile/primitives.h
M src/host/layer23/src/mobile/app_mobile.c
M src/host/layer23/src/mobile/primitives.c
3 files changed, 61 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/31/4931/3

diff --git a/src/host/layer23/include/osmocom/bb/mobile/primitives.h b/src/host/layer23/include/osmocom/bb/mobile/primitives.h
index a3168b2..4d81ba1 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/primitives.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/primitives.h
@@ -14,6 +14,8 @@
 enum mobile_prims {
 	PRIM_MOB_TIMER,
 	PRIM_MOB_TIMER_CANCEL,
+	PRIM_MOB_STARTED,
+	PRIM_MOB_SHUTDOWN,
 };
 
 struct mobile_prim_intf {
@@ -21,6 +23,7 @@
 	void (*indication)(struct mobile_prim_intf *, struct mobile_prim *prim);
 
 	/* Internal state */
+	struct llist_head entry;
 	struct llist_head timers;
 };
 
@@ -33,16 +36,36 @@
 	int seconds;			/*!< Seconds the timer should fire in */
 };
 
+/**
+ * Primitive to indicate starting of the mobile.
+ */
+struct mobile_started_param {
+	bool started;
+};
+
+/**
+ * Primitive to indicate shutdown of the mobile. It will go through
+ * various states.
+ */
+struct mobile_shutdown_param {
+	int old_state;
+	int new_state;
+};
+
 struct mobile_prim {
 	struct osmo_prim_hdr hdr;	/*!< Primitive base class */
 	union {
 		struct mobile_timer_param timer;
+		struct mobile_started_param started;
+		struct mobile_shutdown_param shutdown;
 	} u;
 };
-
 
 struct mobile_prim_intf *mobile_prim_intf_alloc(struct osmocom_ms *ms);
 int mobile_prim_intf_req(struct mobile_prim_intf *intf, struct mobile_prim *hdr);
 void mobile_prim_intf_free(struct mobile_prim_intf *intf);
 
 struct mobile_prim *mobile_prim_alloc(unsigned int primitive, enum osmo_prim_operation op);
+
+void mobile_prim_ntfy_started(struct osmocom_ms *ms, bool started);
+void mobile_prim_ntfy_shutdown(struct osmocom_ms *ms, int old_state, int new_state);
\ No newline at end of file
diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c
index c5c84e6..46cf171 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -37,6 +37,7 @@
 #include <osmocom/bb/mobile/app_mobile.h>
 #include <osmocom/bb/mobile/mncc.h>
 #include <osmocom/bb/mobile/voice.h>
+#include <osmocom/bb/mobile/primitives.h>
 #include <osmocom/bb/common/sap_interface.h>
 #include <osmocom/vty/logging.h>
 #include <osmocom/vty/telnet_interface.h>
@@ -447,9 +448,14 @@
 void mobile_set_started(struct osmocom_ms *ms, bool state)
 {
 	ms->started = state;
+
+	mobile_prim_ntfy_started(ms, state);
 }
 
 void mobile_set_shutdown(struct osmocom_ms *ms, int state)
 {
+	int old_state = ms->shutdown;
 	ms->shutdown = state;
+
+	mobile_prim_ntfy_shutdown(ms, old_state, state);
 }
diff --git a/src/host/layer23/src/mobile/primitives.c b/src/host/layer23/src/mobile/primitives.c
index efa7f3f..dde34bc 100644
--- a/src/host/layer23/src/mobile/primitives.c
+++ b/src/host/layer23/src/mobile/primitives.c
@@ -24,6 +24,8 @@
 #include <osmocom/core/timer.h>
 #include <osmocom/core/talloc.h>
 
+static LLIST_HEAD(s_prims);
+
 struct timer_closure {
 	struct llist_head entry;
 	struct mobile_prim_intf *intf;
@@ -39,6 +41,7 @@
 	intf->ms = ms;
 
 	INIT_LLIST_HEAD(&intf->timers);
+	llist_add_tail(&intf->entry, &s_prims);
 	return intf;
 }
 
@@ -51,6 +54,7 @@
 		llist_del(&timer->entry);
 		talloc_free(timer);
 	}
+	llist_del(&intf->entry);
 	talloc_free(intf);
 }
 
@@ -95,6 +99,33 @@
 	return 0;
 }
 
+static void dispatch(struct osmocom_ms *ms, struct mobile_prim *prim)
+{
+	struct mobile_prim_intf *intf, *tmp;
+
+	llist_for_each_entry_safe(intf, tmp, &s_prims, entry) {
+		if (intf->ms == ms)
+			intf->indication(intf, prim);
+	}
+}
+
+void mobile_prim_ntfy_started(struct osmocom_ms *ms, bool started)
+{
+	struct mobile_prim *prim = mobile_prim_alloc(PRIM_MOB_STARTED, PRIM_OP_INDICATION);
+
+	prim->u.started.started = started;
+	dispatch(ms, prim);
+}
+
+void mobile_prim_ntfy_shutdown(struct osmocom_ms *ms, int old_state, int new_state)
+{
+	struct mobile_prim *prim = mobile_prim_alloc(PRIM_MOB_SHUTDOWN, PRIM_OP_INDICATION);
+
+	prim->u.shutdown.old_state = old_state;
+	prim->u.shutdown.new_state = new_state;
+	dispatch(ms, prim);
+}
+
 static int cancel_timer(struct mobile_prim_intf *intf, struct mobile_timer_param *param)
 {
 	struct timer_closure *closure;

-- 
To view, visit https://gerrit.osmocom.org/4931
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I5df20a4ab79c06b515780675b6df2929aa976f0d
Gerrit-PatchSet: 3
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list