Change in osmo-sgsn[master]: gprs_gmm_fsm.c: Implement RAT change between 2g and 3g

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

laforge gerrit-no-reply at lists.osmocom.org
Thu Feb 6 16:20:16 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/15487 )

Change subject: gprs_gmm_fsm.c: Implement RAT change between 2g and 3g
......................................................................

gprs_gmm_fsm.c: Implement RAT change between 2g and 3g

Related: OS#2737
Change-Id: I3fc614da6ba137e871ee0fe86ca22b6a4a354dd2
---
M include/osmocom/sgsn/gprs_gmm_fsm.h
M src/sgsn/gprs_gmm.c
M src/sgsn/gprs_gmm_fsm.c
3 files changed, 63 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/include/osmocom/sgsn/gprs_gmm_fsm.h b/include/osmocom/sgsn/gprs_gmm_fsm.h
index fd5b4bf..f10851e 100644
--- a/include/osmocom/sgsn/gprs_gmm_fsm.h
+++ b/include/osmocom/sgsn/gprs_gmm_fsm.h
@@ -1,6 +1,8 @@
 #pragma once
 
 #include <osmocom/core/fsm.h>
+#include <osmocom/sgsn/gprs_sgsn.h>
+
 
 /* 3GPP TS 24.008 § 4.1.3.3 GMM mobility management states on the network side */
 enum gmm_fsm_states {
@@ -23,6 +25,12 @@
 	E_GMM_SUSPEND,
 	E_GMM_RESUME,
 	E_GMM_CLEANUP,
+	E_GMM_RAT_CHANGE,
+};
+
+struct gmm_rat_change_data {
+	enum sgsn_ran_type new_ran_type;
+	struct gprs_llc_llme *llme;
 };
 
 static inline bool gmm_fsm_is_registered(struct osmo_fsm_inst *fi)
diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c
index c574dac..03ff513 100644
--- a/src/sgsn/gprs_gmm.c
+++ b/src/sgsn/gprs_gmm.c
@@ -1109,6 +1109,23 @@
 	return false;
 }
 
+/* Notify the FSM of a RAT change */
+static void mmctx_handle_rat_change(struct sgsn_mm_ctx *mmctx, struct msgb *msg, struct gprs_llc_llme *llme)
+{
+	struct gmm_rat_change_data rat_chg = {
+		.llme = llme
+	};
+
+	rat_chg.new_ran_type = MSG_IU_UE_CTX(msg) ? MM_CTX_T_UTRAN_Iu : MM_CTX_T_GERAN_Gb;
+
+	if (rat_chg.new_ran_type != mmctx->ran_type)
+		osmo_fsm_inst_dispatch(mmctx->gmm_fsm, E_GMM_RAT_CHANGE, (void *) &rat_chg);
+	else
+		LOGMMCTXP(LOGL_ERROR, mmctx, "RAT didn't change or not implemented (ran_type=%u, "
+				"msg_iu_ue_ctx=%p\n", mmctx->ran_type, MSG_IU_UE_CTX(msg));
+
+}
+
 /* 3GPP TS 24.008 § 9.4.1 Attach request */
 static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg,
 				struct gprs_llc_llme *llme)
@@ -1234,6 +1251,9 @@
 		goto rejected;
 	}
 
+	if (mmctx_did_rat_change(ctx, msg))
+		mmctx_handle_rat_change(ctx, msg, llme);
+
 	if (ctx->ran_type == MM_CTX_T_GERAN_Gb) {
 		ctx->gb.tlli = msgb_tlli(msg);
 		ctx->gb.llme = llme;
@@ -1614,7 +1634,12 @@
 				mmctx->p_tmsi, mmctx->p_tmsi_old,
 				mmctx->gb.tlli, mmctx->gb.tlli_new,
 				osmo_rai_name(&mmctx->ra));
-			osmo_fsm_inst_dispatch(mmctx->gmm_fsm, E_GMM_COMMON_PROC_INIT_REQ, NULL);
+			/* A RAT change will trigger the common procedure
+			 * below after handling the RAT change. Protect it
+			 * here from being called twice */
+			if (!mmctx_did_rat_change(mmctx, msg))
+				osmo_fsm_inst_dispatch(mmctx->gmm_fsm, E_GMM_COMMON_PROC_INIT_REQ, NULL);
+
 		}
 	} else if (!gprs_ra_id_equals(&mmctx->ra, &old_ra_id) ||
 		mmctx->gmm_fsm->state == ST_GMM_DEREGISTERED)
@@ -1646,6 +1671,11 @@
 		goto rejected;
 	}
 
+	if (mmctx_did_rat_change(mmctx, msg)) {
+		mmctx_handle_rat_change(mmctx, msg, llme);
+		osmo_fsm_inst_dispatch(mmctx->gmm_fsm, E_GMM_COMMON_PROC_INIT_REQ, NULL);
+	}
+
 	/* Store new BVCI/NSEI in MM context (FIXME: delay until we ack?) */
 	msgid2mmctx(mmctx, msg);
 	/* Bump the statistics of received signalling msgs for this MM context */
diff --git a/src/sgsn/gprs_gmm_fsm.c b/src/sgsn/gprs_gmm_fsm.c
index 94ecb50..37ea904 100644
--- a/src/sgsn/gprs_gmm_fsm.c
+++ b/src/sgsn/gprs_gmm_fsm.c
@@ -1,6 +1,8 @@
 #include <osmocom/core/tdef.h>
 
 #include <osmocom/sgsn/gprs_gmm_fsm.h>
+#include <osmocom/sgsn/gprs_mm_state_gb_fsm.h>
+#include <osmocom/sgsn/gprs_mm_state_iu_fsm.h>
 
 #include <osmocom/sgsn/debug.h>
 #include <osmocom/sgsn/sgsn.h>
@@ -149,11 +151,32 @@
 	/* OSMO_VALUE_STRING(E_GMM_DETACH_ACCEPTED), */
 	OSMO_VALUE_STRING(E_GMM_SUSPEND),
 	OSMO_VALUE_STRING(E_GMM_CLEANUP),
+	OSMO_VALUE_STRING(E_GMM_RAT_CHANGE),
 	{ 0, NULL }
 };
 
 void gmm_fsm_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *data) {
+	struct sgsn_mm_ctx *mmctx = fi->priv;
+	struct gmm_rat_change_data *rat_chg = (struct gmm_rat_change_data *)data;
+
 	switch (event) {
+	case E_GMM_RAT_CHANGE:
+
+		switch (fi->state) {
+		case ST_GMM_COMMON_PROC_INIT:
+			gmm_fsm_state_chg(fi, ST_GMM_DEREGISTERED);
+		default:
+			if (mmctx->ran_type == MM_CTX_T_GERAN_Gb)
+				osmo_fsm_inst_dispatch(mmctx->gb.mm_state_fsm, E_MM_IMPLICIT_DETACH, NULL);
+			else if (mmctx->ran_type == MM_CTX_T_UTRAN_Iu) {
+				osmo_fsm_inst_dispatch(mmctx->iu.mm_state_fsm, E_PMM_IMPLICIT_DETACH, NULL);
+				mmctx->gb.llme = rat_chg->llme;
+			}
+
+			mmctx->ran_type = rat_chg->new_ran_type;
+			break;
+		}
+
 	case E_GMM_CLEANUP:
 		switch (fi->state) {
 		case ST_GMM_DEREGISTERED:
@@ -175,7 +198,7 @@
 	.states = gmm_fsm_states,
 	.num_states = ARRAY_SIZE(gmm_fsm_states),
 	.event_names = gmm_fsm_event_names,
-	.allstate_event_mask = X(E_GMM_CLEANUP),
+	.allstate_event_mask = X(E_GMM_CLEANUP) | X(E_GMM_RAT_CHANGE),
 	.allstate_action = gmm_fsm_allstate_action,
 	.log_subsys = DMM,
 	.timer_cb = gmm_fsm_timer_cb,

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

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I3fc614da6ba137e871ee0fe86ca22b6a4a354dd2
Gerrit-Change-Number: 15487
Gerrit-PatchSet: 14
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-CC: fixeria <axilirator at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200206/cc6eb015/attachment.htm>


More information about the gerrit-log mailing list