aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-08-29 19:59:07 +0200
committerpespin <pespin@sysmocom.de>2019-09-02 09:42:21 +0000
commit0b72240799c1cc961645a714a78b8c0209fdd7ab (patch)
tree4ce7b28ebaf54d0b3173f7261771e2d3a3720700
parent8333ef10c9e2a3806e04dd9512dbb141d6cb13cc (diff)
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
-rw-r--r--include/osmocom/sgsn/gprs_gmm.h4
-rw-r--r--include/osmocom/sgsn/gprs_sgsn.h22
-rw-r--r--src/gprs/gprs_gb.c2
-rw-r--r--src/gprs/gprs_gmm.c45
-rw-r--r--src/gprs/gprs_ranap.c2
-rw-r--r--src/gprs/gprs_sgsn.c4
6 files changed, 43 insertions, 36 deletions
diff --git a/include/osmocom/sgsn/gprs_gmm.h b/include/osmocom/sgsn/gprs_gmm.h
index 93163515..6c72cda3 100644
--- a/include/osmocom/sgsn/gprs_gmm.h
+++ b/include/osmocom/sgsn/gprs_gmm.h
@@ -49,9 +49,9 @@ void extract_subscr_hlr(struct sgsn_mm_ctx *ctx);
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 eea9fb0b..f64e07b1 100644
--- a/include/osmocom/sgsn/gprs_sgsn.h
+++ b/include/osmocom/sgsn/gprs_sgsn.h
@@ -32,14 +32,17 @@ enum gprs_gmm_state {
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 @@ struct sgsn_mm_ctx {
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 @@ struct sgsn_mm_ctx {
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 @@ struct sgsn_mm_ctx {
/* 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 29bfc53e..43af4347 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 33ade4d8..badb881c 100644
--- a/src/gprs/gprs_gmm.c
+++ b/src/gprs/gprs_gmm.c
@@ -102,16 +102,20 @@ static const struct tlv_definition gsm48_sm_att_tlvdef = {
},
};
-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(PMM_DETACHED),
+ OSMO_VALUE_STRING(PMM_CONNECTED),
+ OSMO_VALUE_STRING(PMM_IDLE),
+ { 0, NULL }
+};
+
static void mmctx_change_gtpu_endpoints_to_sgsn(struct sgsn_mm_ctx *mm_ctx)
{
struct sgsn_pdp_ctx *pdp;
@@ -130,14 +134,14 @@ static void mmctx_state_timer_cb(void *_mm)
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 @@ static void mmctx_state_timer_stop(struct sgsn_mm_ctx *mm, unsigned int T)
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 @@ void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state)
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_gb_names, state));
switch (state) {
case MM_READY:
@@ -216,19 +220,16 @@ void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state)
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 e0470f60..836937b6 100644
--- a/src/gprs/gprs_ranap.c
+++ b/src/gprs/gprs_ranap.c
@@ -138,7 +138,7 @@ int sgsn_ranap_iu_event(struct ranap_ue_conn_ctx *ctx, enum ranap_iu_event_type
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 ee1902c2..2116590d 100644
--- a/src/gprs/gprs_sgsn.c
+++ b/src/gprs/gprs_sgsn.c
@@ -228,7 +228,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli,
ctx->ran_type = MM_CTX_T_GERAN_Gb;
ctx->gb.tlli = tlli;
ctx->gmm_state = GMM_DEREGISTERED;
- ctx->pmm_state = MM_IDLE;
+ ctx->gb.mm_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",
@@ -263,7 +263,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx)
ctx->iu.ue_ctx->rab_assign_addr_enc = sgsn->cfg.iu.rab_assign_addr_enc;
ctx->iu.new_key = 1;
ctx->gmm_state = GMM_DEREGISTERED;
- ctx->pmm_state = PMM_DETACHED;
+ ctx->iu.mm_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) {