ms: Rewrite MS release lifecycle

This commit changes lots of stuff in the MS release lifecycle, but
there's no really good way to split this into patches which make sense,
since all the chaos is intensively entangled.

Get rid of the ms_callback complex mess, it is not needed at all.

Previous MS release was strange due to the existance of previous
ms_callback.idle concept and MS storage: the MS signalled when it went
idle (no TBFs attached) and waited for somebody outside to free it,
while then arming itself the release timer to release itself if it was
not released by whoever.

The new lifecycle follows an easier (expected) approach: Whenever all
TBFs become detached from the MS and it becomes idle (use_count becomes
0), then it frees its reserved resources (TFI, etc.) and either:
* frees itself immediatelly under certain conditions (release timeout
  configured = 0 or MS garbage with TLLI=GSM_RESERVED_TMSI)
* Arms release_timer and frees itself when it triggers.

If during release_timer the MS is required again (for instance because a
new TBF with TLLI/IMSI of the MS is observed), then a TBF is attached to
the MS and it is considered to become active again, hence the release_timer
is stopped.

OS#6002
Change-Id: Ibe5115bc15bb4d76026918adc1be79469c2f4839
diff --git a/src/gprs_ms.h b/src/gprs_ms.h
index 123db0e..cdb23bf 100644
--- a/src/gprs_ms.h
+++ b/src/gprs_ms.h
@@ -51,14 +51,8 @@
 struct gprs_rlcmac_trx;
 struct GprsMs;
 
-struct gpr_ms_callback {
-	void (*ms_idle)(struct GprsMs *);
-	void (*ms_active)(struct GprsMs *);
-};
-
 struct GprsMs {
 	struct llist_head list; /* list of all GprsMs */
-	struct gpr_ms_callback cb;
 	bool app_info_pending;
 
 	struct gprs_rlcmac_bts *bts;
@@ -84,7 +78,6 @@
 	struct gprs_llc_queue llc_queue;
 	struct osmo_timer_list llc_timer;
 
-	bool is_idle;
 	struct osmo_use_count use_count;
 	struct osmo_timer_list timer;
 	unsigned delay;
@@ -140,8 +133,6 @@
 const char *ms_name(const struct GprsMs *ms);
 char *ms_name_buf(const struct GprsMs *ms, char *buf, unsigned int buf_size);
 
-void ms_set_callback(struct GprsMs *ms, struct gpr_ms_callback *cb);
-
 int ms_nacc_start(struct GprsMs *ms, Packet_Cell_Change_Notification_t *notif);
 bool ms_nacc_rts(const struct GprsMs *ms);
 struct msgb *ms_nacc_create_rlcmac_msg(struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf,
@@ -157,8 +148,7 @@
 static inline bool ms_is_idle(const struct GprsMs *ms)
 {
 	return !ms->ul_tbf && !ms->dl_tbf &&
-		llist_empty(&ms->old_tbfs) &&
-		osmo_use_count_total(&ms->use_count) == 0;
+		llist_empty(&ms->old_tbfs);
 }
 
 static inline struct gprs_llc_queue *ms_llc_queue(struct GprsMs *ms)
@@ -251,7 +241,7 @@
 	return ms->current_trx;
 }
 
-#define MS_USE_RELEASE_TIMER "release_timer"
+#define MS_USE_TBF "tbf"
 #define ms_ref(ms, use) \
 	OSMO_ASSERT(osmo_use_count_get_put(&(ms)->use_count, use, 1) == 0)
 #define ms_unref(ms, use) \