pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-gprs/+/32580 )

Change subject: gmm: Rework sess_id to identify one GMME
......................................................................

gmm: Rework sess_id to identify one GMME

The GMM layer doesn't really have to differentiate between SM
connections, everything is sent over the LLC "GMM" SAPI.
However, we still want to identify/related a given MS if there are
multiple MS using the stack.

Change-Id: Ib757f016824d918ce8b74ae0c2a652a6c1823556
---
M include/osmocom/gprs/gmm/gmm_ms_fsm.h
M include/osmocom/gprs/gmm/gmm_private.h
M src/gmm/gmm.c
M src/gmm/gmm_ms_fsm.c
M src/gmm/gmm_prim.c
5 files changed, 32 insertions(+), 41 deletions(-)

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




diff --git a/include/osmocom/gprs/gmm/gmm_ms_fsm.h 
b/include/osmocom/gprs/gmm/gmm_ms_fsm.h
index 516801e..078c535 100644
--- a/include/osmocom/gprs/gmm/gmm_ms_fsm.h
+++ b/include/osmocom/gprs/gmm/gmm_ms_fsm.h
@@ -48,9 +48,6 @@
        bool with_imsi;
        bool explicit_att; /* true if by SMREG-ATTACH.req requested it */
        bool implicit_att; /* true if GMMSM-ESTABLISH.req requested it */
-       /* Session Ids waiting for attach to happen during implicit_att: */
-       uint32_t sess_id[16];
-       uint8_t num_sess_id;
        /* Retransmission of ATTACH REQUEST (T3310) */
        uint8_t req_attempts;
 };
@@ -78,8 +75,7 @@
 int gprs_gmm_ms_fsm_ctx_request_attach(struct gprs_gmm_ms_fsm_ctx *ctx,
                                       enum osmo_gprs_gmm_attach_type 
attach_type,
                                       bool attach_with_imsi,
-                                      bool explicit_attach,
-                                      uint32_t sess_id);
+                                      bool explicit_attach);

 int gprs_gmm_ms_fsm_ctx_request_detach(struct gprs_gmm_ms_fsm_ctx *ctx,
                                       enum osmo_gprs_gmm_detach_ms_type 
detach_type,
diff --git a/include/osmocom/gprs/gmm/gmm_private.h 
b/include/osmocom/gprs/gmm/gmm_private.h
index bdff1c1..6abf3be 100644
--- a/include/osmocom/gprs/gmm/gmm_private.h
+++ b/include/osmocom/gprs/gmm/gmm_private.h
@@ -20,6 +20,8 @@
 /* 3GPP TS 44.064 ยง 8.3 TLLI assignment procedures */
 #define GPRS_GMM_TLLI_UNASSIGNED (0xffffffff)

+#define GPRS_GMM_SESS_ID_UNASSIGNED (0xffffffff)
+
 extern int g_gmm_log_cat[_OSMO_GPRS_GMM_LOGC_MAX];

 #define LOGGMM(lvl, fmt, args...) LOGP(g_gmm_log_cat[OSMO_GPRS_GMM_LOGC_GMM], 
lvl, fmt, ## args)
@@ -53,6 +55,7 @@
        struct llist_head list; /* item in (struct gprs_gmm_ctx)->gmme_list */

        struct gprs_gmm_ms_fsm_ctx ms_fsm;
+       uint32_t sess_id; /* Used to identify the GMME in GMMSM SAP */
        uint32_t ptmsi;
        uint32_t old_ptmsi;
        uint32_t tlli;
diff --git a/src/gmm/gmm.c b/src/gmm/gmm.c
index 8f54f04..980f8f4 100644
--- a/src/gmm/gmm.c
+++ b/src/gmm/gmm.c
@@ -149,6 +149,7 @@
                return NULL;
        }

+       gmme->sess_id = GPRS_GMM_SESS_ID_UNASSIGNED;
        gmme->ptmsi = ptmsi;
        gmme->old_ptmsi = GSM_RESERVED_TMSI;
        gmme->old_tlli = GPRS_GMM_TLLI_UNASSIGNED;
diff --git a/src/gmm/gmm_ms_fsm.c b/src/gmm/gmm_ms_fsm.c
index 85aa6bf..6f82815 100644
--- a/src/gmm/gmm_ms_fsm.c
+++ b/src/gmm/gmm_ms_fsm.c
@@ -132,14 +132,11 @@

                if (att.implicit_att) {
                        /* Submit GMMSM-ESTABLISH-CNF as per TS 24.007 Annex 
C.3 */
-                       unsigned int i;
-                       for (i = 0; i < att.num_sess_id; i++) {
-                               rc = 
gprs_gmm_submit_gmmsm_establish_cnf(ctx->gmme,
-                                                                        
att.sess_id[i],
-                                                                        false, 
cause);
-                               if (rc < 0)
-                                       return;
-                       }
+                       rc = gprs_gmm_submit_gmmsm_establish_cnf(ctx->gmme,
+                                                                
ctx->gmme->sess_id,
+                                                                false, cause);
+                       if (rc < 0)
+                               return;
                }
                break;
        case GPRS_GMM_MS_EV_ATTACH_ACCEPTED:
@@ -153,12 +150,9 @@
                }
                if (ctx->attach.implicit_att) {
                        /* Submit GMMSM-ESTABLISH-CNF as per TS 24.007 Annex 
C.3 */
-                       unsigned int i;
-                       for (i = 0; i < ctx->attach.num_sess_id; i++) {
-                               rc = 
gprs_gmm_submit_gmmsm_establish_cnf(ctx->gmme, ctx->attach.sess_id[i], true, 0);
-                               if (rc < 0)
-                                       return;
-                       }
+                       rc = gprs_gmm_submit_gmmsm_establish_cnf(ctx->gmme, 
ctx->gmme->sess_id, true, 0);
+                       if (rc < 0)
+                               return;
                }
                break;
        case GPRS_GMM_MS_EV_DETACH_REQUESTED:
@@ -419,8 +413,7 @@
 int gprs_gmm_ms_fsm_ctx_request_attach(struct gprs_gmm_ms_fsm_ctx *ctx,
                                       enum osmo_gprs_gmm_attach_type 
attach_type,
                                       bool attach_with_imsi,
-                                      bool explicit_attach,
-                                      uint32_t sess_id)
+                                      bool explicit_attach)
 {
        int rc;

@@ -431,23 +424,6 @@
        else
                ctx->attach.implicit_att = true;

-       if (!explicit_attach) {
-               unsigned int i;
-               bool found = false;
-               if (ctx->attach.num_sess_id == ARRAY_SIZE(ctx->attach.sess_id))
-                       return -ENOMEM;
-               for (i = 0; i < ctx->attach.num_sess_id; i++) {
-                       if (sess_id == ctx->attach.sess_id[i]) {
-                               found = true;
-                               break;
-                       }
-               }
-               if (!found) {
-                       ctx->attach.sess_id[ctx->attach.num_sess_id] = sess_id;
-                       ctx->attach.num_sess_id++;
-               }
-       }
-
        rc = osmo_fsm_inst_dispatch(ctx->fi, GPRS_GMM_MS_EV_ATTACH_REQUESTED, 
NULL);
        return rc;
 }
diff --git a/src/gmm/gmm_prim.c b/src/gmm/gmm_prim.c
index 2d53a0a..8f8d218 100644
--- a/src/gmm/gmm_prim.c
+++ b/src/gmm/gmm_prim.c
@@ -389,7 +389,7 @@
        rc = gprs_gmm_ms_fsm_ctx_request_attach(&gmme->ms_fsm,
                                                
gmm_prim->gmmreg.attach_req.attach_type,
                                                
gmm_prim->gmmreg.attach_req.attach_with_imsi,
-                                               true, 0);
+                                               true);
        return rc;
 }

@@ -485,6 +485,8 @@
        gmme = 
gprs_gmm_gmme_find_or_create_by_ptmsi_imsi(gmm_prim->gmmsm.establish_req.ptmsi,
                                                          
gmm_prim->gmmsm.establish_req.imsi);
        OSMO_ASSERT(gmme);
+       /* Identify this GMME with this sess_id in GMMSM SAP from now on: */
+       gmme->sess_id = gmm_prim->gmmsm.sess_id;

        if (gmme->ms_fsm.fi->state == GPRS_GMM_MS_ST_REGISTERED) {
                rc = gprs_gmm_submit_gmmsm_establish_cnf(gmme, 
gmm_prim->gmmsm.sess_id, true, 0);
@@ -499,8 +501,7 @@
        rc = gprs_gmm_ms_fsm_ctx_request_attach(&gmme->ms_fsm,
                                                
gmm_prim->gmmsm.establish_req.attach_type,
                                                
gmm_prim->gmmsm.establish_req.attach_with_imsi,
-                                               false,
-                                               gmm_prim->gmmsm.sess_id);
+                                               false);
        return rc;
 }


--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32580
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: Ib757f016824d918ce8b74ae0c2a652a6c1823556
Gerrit-Change-Number: 32580
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to