Change in ...osmo-sgsn[master]: Split enum gprs_pmm_state into Iu and Gb counterparts

pespin gerrit-no-reply at lists.osmocom.org
Thu Aug 29 18:28:29 UTC 2019


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/15337


Change subject: Split enum gprs_pmm_state into Iu and Gb counterparts
......................................................................

Split enum gprs_pmm_state into Iu and Gb counterparts

Those two state sets are not part of the same state machine, and are
used in different scenarios, so let's split them and handle them in Gb
and Iu specific parts of struct sgsn_mm_ctx. This is required in order
to improve related code (for instance, use osmocom fsm).

Change-Id: I6100d607da316da0595886c6968704dd9ccfbde9
---
M include/osmocom/sgsn/gprs_gmm.h
M include/osmocom/sgsn/gprs_sgsn.h
M src/gprs/gprs_gb.c
M src/gprs/gprs_gmm.c
M src/gprs/gprs_ranap.c
M src/gprs/gprs_sgsn.c
6 files changed, 43 insertions(+), 36 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/37/15337/1

diff --git a/include/osmocom/sgsn/gprs_gmm.h b/include/osmocom/sgsn/gprs_gmm.h
index 9316351..6c72cda 100644
--- a/include/osmocom/sgsn/gprs_gmm.h
+++ b/include/osmocom/sgsn/gprs_gmm.h
@@ -49,9 +49,9 @@
 
 void pdp_ctx_detach_mm_ctx(struct sgsn_pdp_ctx *pdp);
 
-void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state);
+void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_mm_state_iu state);
 void mmctx_state_timer_start(struct sgsn_mm_ctx *mm, unsigned int T);
-void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state);
+void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_mm_state_gb state);
 
 void msgid2mmctx(struct sgsn_mm_ctx *mm, const struct msgb *msg);
 #endif /* _GPRS_GMM_H */
diff --git a/include/osmocom/sgsn/gprs_sgsn.h b/include/osmocom/sgsn/gprs_sgsn.h
index 5fef89e..581164d 100644
--- a/include/osmocom/sgsn/gprs_sgsn.h
+++ b/include/osmocom/sgsn/gprs_sgsn.h
@@ -32,14 +32,17 @@
 	GMM_DEREGISTERED_INIT,		/* 4.1.3.3.1.4 */
 };
 
-/* TS 23.060 6.1.1 and 6.1.2 Mobility management states A/Gb and Iu mode */
-enum gprs_pmm_state {
-	PMM_DETACHED,
-	PMM_CONNECTED,
-	PMM_IDLE,
+/* TS 23.060 6.1.1 Mobility Management States (A/Gb mode) */
+enum gprs_mm_state_gb {
 	MM_IDLE,
 	MM_READY,
-	MM_STANDBY,
+	MM_STANDBY
+};
+/* TS 23.060 6.1.2 Mobility Management States (Iu mode) */
+enum gprs_mm_state_iu {
+	PMM_DETACHED,
+	PMM_CONNECTED,
+	PMM_IDLE
 };
 
 enum gprs_mm_ctr {
@@ -138,7 +141,6 @@
 
 	char 			imsi[GSM23003_IMSI_MAX_DIGITS+1];
 	enum gprs_gmm_state	gmm_state;
-	enum gprs_pmm_state	pmm_state;	/* Iu: page when in PMM-IDLE mode */
 	uint32_t 		p_tmsi;
 	uint32_t 		p_tmsi_old;	/* old P-TMSI before new is confirmed */
 	uint32_t 		p_tmsi_sig;
@@ -158,9 +160,11 @@
 		uint32_t		tlli;
 		uint32_t		tlli_new;
 
+		/* TS 23.060 6.1.1 Mobility Management States (A/Gb mode) */
+		enum gprs_mm_state_gb	mm_state;
 		/* timer for mm state. state=READY: T3314 (aka TS 23.060 "READY timer") */
 		struct osmo_timer_list  state_timer;
-		unsigned int		state_T;	/* Txxxx number but only used for pmm_states */
+		unsigned int		state_T;	/* Txxxx number but only used for mm_state */
 	} gb;
 	struct {
 		int			new_key;
@@ -175,6 +179,8 @@
 		/* Voice Support Match Indicator */
 		struct ranap_ue_conn_ctx	*ue_ctx;
 		struct service_info	service;
+		/* TS 23.060 6.1.2 Mobility Management States (Iu mode) */
+		enum gprs_mm_state_iu	mm_state;
 	} iu;
 	struct {
 		struct osmo_fsm_inst *fsm;
diff --git a/src/gprs/gprs_gb.c b/src/gprs/gprs_gb.c
index 29bfc53..43af434 100644
--- a/src/gprs/gprs_gb.c
+++ b/src/gprs/gprs_gb.c
@@ -35,7 +35,7 @@
 /* Update the MM context state */
 static void gsm0408_gprs_notify_pdu_gb(struct sgsn_mm_ctx *mmctx)
 {
-	switch (mmctx->pmm_state) {
+	switch (mmctx->gb.mm_state) {
 	case MM_STANDBY:
 		mmctx_set_mm_state(mmctx, MM_READY);
 		break;
diff --git a/src/gprs/gprs_gmm.c b/src/gprs/gprs_gmm.c
index e5fa047..189187c 100644
--- a/src/gprs/gprs_gmm.c
+++ b/src/gprs/gprs_gmm.c
@@ -102,10 +102,14 @@
 	},
 };
 
-static const struct value_string gprs_pmm_state_names[] = {
-	OSMO_VALUE_STRING(PMM_DETACHED),
-	OSMO_VALUE_STRING(PMM_CONNECTED),
-	OSMO_VALUE_STRING(PMM_IDLE),
+static const struct value_string gprs_mm_state_gb_names[] = {
+	OSMO_VALUE_STRING(MM_IDLE),
+	OSMO_VALUE_STRING(MM_READY),
+	OSMO_VALUE_STRING(MM_STANDBY),
+	{ 0, NULL }
+};
+
+static const struct value_string gprs_mm_state_iu_names[] = {
 	OSMO_VALUE_STRING(MM_IDLE),
 	OSMO_VALUE_STRING(MM_READY),
 	OSMO_VALUE_STRING(MM_STANDBY),
@@ -130,14 +134,14 @@
 
 	switch (mm->gb.state_T) {
 	case 3314:
-		switch (mm->pmm_state) {
+		switch (mm->gb.mm_state) {
 		case MM_READY:
 			LOGMMCTXP(LOGL_INFO, mm, "T3314 expired\n");
 			mmctx_set_mm_state(mm, MM_STANDBY);
 			break;
 		default:
 			LOGMMCTXP(LOGL_ERROR, mm, "T3314 expired in state %s != MM_READY\n",
-				  get_value_string(gprs_pmm_state_names, mm->pmm_state));
+				  get_value_string(gprs_mm_state_gb_names, mm->gb.mm_state));
 			break;
 		}
 		break;
@@ -174,16 +178,16 @@
 	mm->gb.state_T = 0;
 }
 
-void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state)
+void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_mm_state_iu state)
 {
 	OSMO_ASSERT(ctx->ran_type == MM_CTX_T_UTRAN_Iu);
 
-	if (ctx->pmm_state == state)
+	if (ctx->iu.mm_state == state)
 		return;
 
 	LOGMMCTXP(LOGL_INFO, ctx, "Changing PMM state from %s to %s\n",
-		  get_value_string(gprs_pmm_state_names, ctx->pmm_state),
-		  get_value_string(gprs_pmm_state_names, state));
+		  get_value_string(gprs_mm_state_iu_names, ctx->iu.mm_state),
+		  get_value_string(gprs_mm_state_iu_names, state));
 
 	switch (state) {
 	case PMM_IDLE:
@@ -192,23 +196,23 @@
 		break;
 	case PMM_CONNECTED:
 		break;
-	default:
+	case PMM_DETACHED:
 		break;
 	}
 
-	ctx->pmm_state = state;
+	ctx->iu.mm_state = state;
 }
 
-void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state)
+void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_mm_state_gb state)
 {
 	OSMO_ASSERT(ctx->ran_type == MM_CTX_T_GERAN_Gb);
 
-	if (ctx->pmm_state == state)
+	if (ctx->gb.mm_state == state)
 		return;
 
 	LOGMMCTXP(LOGL_INFO, ctx, "Changing MM state from %s to %s\n",
-		  get_value_string(gprs_pmm_state_names, ctx->pmm_state),
-		  get_value_string(gprs_pmm_state_names, state));
+		  get_value_string(gprs_mm_state_gb_names, ctx->gb.mm_state),
+		  get_value_string(gprs_mm_state_iu_names, state));
 
 	switch (state) {
 	case MM_READY:
@@ -216,19 +220,16 @@
 		mmctx_state_timer_start(ctx, 3314);
 		break;
 	case MM_IDLE:
-		if (ctx->pmm_state == MM_READY)
+		if (ctx->gb.mm_state == MM_READY)
 			mmctx_state_timer_stop(ctx, 3314);
 		break;
 	case MM_STANDBY:
-		if (ctx->pmm_state == MM_READY)
+		if (ctx->gb.mm_state == MM_READY)
 			mmctx_state_timer_stop(ctx, 3314);
 		break;
-	default:
-		/* when changing to state != MM_READY */
-		break;
 	}
 
-	ctx->pmm_state = state;
+	ctx->gb.mm_state = state;
 }
 
 /* Our implementation, should be kept in SGSN */
diff --git a/src/gprs/gprs_ranap.c b/src/gprs/gprs_ranap.c
index 5d2adee..e835af7 100644
--- a/src/gprs/gprs_ranap.c
+++ b/src/gprs/gprs_ranap.c
@@ -139,7 +139,7 @@
 			LOGMMCTXP(LOGL_INFO, mm, "IU release for imsi %s\n", mm->imsi);
 		else
 			LOGIUP(ctx, LOGL_INFO, "IU release\n");
-		if (mm && mm->pmm_state == PMM_CONNECTED)
+		if (mm && mm->iu.mm_state == PMM_CONNECTED)
 			mmctx_set_pmm_state(mm, PMM_IDLE);
 		rc = 0;
 		break;
diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c
index ee1902c..b395852 100644
--- a/src/gprs/gprs_sgsn.c
+++ b/src/gprs/gprs_sgsn.c
@@ -227,8 +227,8 @@
 	memcpy(&ctx->ra, raid, sizeof(ctx->ra));
 	ctx->ran_type = MM_CTX_T_GERAN_Gb;
 	ctx->gb.tlli = tlli;
+	ctx->gb.mm_state = MM_IDLE;
 	ctx->gmm_state = GMM_DEREGISTERED;
-	ctx->pmm_state = MM_IDLE;
 	ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL;
 	ctx->ciph_algo = sgsn->cfg.cipher;
 	LOGMMCTXP(LOGL_DEBUG, ctx, "Allocated with %s cipher.\n",
@@ -262,8 +262,8 @@
 	ctx->iu.ue_ctx = ue_ctx;
 	ctx->iu.ue_ctx->rab_assign_addr_enc = sgsn->cfg.iu.rab_assign_addr_enc;
 	ctx->iu.new_key = 1;
+	ctx->iu.mm_state = PMM_DETACHED;
 	ctx->gmm_state = GMM_DEREGISTERED;
-	ctx->pmm_state = PMM_DETACHED;
 	ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL;
 	ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, ue_ctx->conn_id);
 	if (!ctx->ctrg) {

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

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I6100d607da316da0595886c6968704dd9ccfbde9
Gerrit-Change-Number: 15337
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190829/0e7c574c/attachment.html>


More information about the gerrit-log mailing list