From 7bbdcc441492ea4b99b0f808d06f6cf3b67d1754 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Wed, 24 May 2023 18:30:57 +0200 Subject: [PATCH] gmm: Provide rlcmac with IMSI & PTMSI information This information will be needed once the GRR layer starts listening for paging requests, which identify MS by either PTMSI or IMSI. Change-Id: I3a0c4a57c3d624c3ebb40ae2cc0c96626ccc2c99 --- include/osmocom/gprs/gmm/gmm_prim.h | 2 ++ include/osmocom/gprs/rlcmac/gre.h | 4 ++++ include/osmocom/gprs/rlcmac/rlcmac_prim.h | 2 ++ src/gmm/gmm.c | 2 ++ src/rlcmac/gre.c | 1 + src/rlcmac/rlcmac_prim.c | 7 +++++++ tests/rlcmac/rlcmac_prim_test.c | 8 ++++++++ 7 files changed, 26 insertions(+) diff --git a/include/osmocom/gprs/gmm/gmm_prim.h b/include/osmocom/gprs/gmm/gmm_prim.h index 4b8657f..b774ef8 100644 --- a/include/osmocom/gprs/gmm/gmm_prim.h +++ b/include/osmocom/gprs/gmm/gmm_prim.h @@ -185,6 +185,8 @@ struct osmo_gprs_gmm_gmmrr_prim { /* OSMO_GPRS_GMM_GMMRR_ASSIGN | Req */ struct { uint32_t new_tlli; + uint32_t ptmsi; + char imsi[OSMO_IMSI_BUF_SIZE]; } assign_req; /* OSMO_GPRS_GMM_GMMRR_PAGE | Ind */ struct { diff --git a/include/osmocom/gprs/rlcmac/gre.h b/include/osmocom/gprs/rlcmac/gre.h index 358d0aa..3afeadc 100644 --- a/include/osmocom/gprs/rlcmac/gre.h +++ b/include/osmocom/gprs/rlcmac/gre.h @@ -12,6 +12,10 @@ struct gprs_rlcmac_entity { struct llist_head entry; /* item in (struct gprs_rlcmac_ctx)->gre_list */ uint32_t tlli; + /* Used to match paging requests coming from CS domain: */ + uint32_t ptmsi; + char imsi[OSMO_IMSI_BUF_SIZE]; + struct gprs_rlcmac_llc_queue *llc_queue; /* Manage TBF Starting Time delay during TBF assignment: */ diff --git a/include/osmocom/gprs/rlcmac/rlcmac_prim.h b/include/osmocom/gprs/rlcmac/rlcmac_prim.h index c44de22..fa1ee52 100644 --- a/include/osmocom/gprs/rlcmac/rlcmac_prim.h +++ b/include/osmocom/gprs/rlcmac/rlcmac_prim.h @@ -91,6 +91,8 @@ struct osmo_gprs_rlcmac_gmmrr_prim { /* OSMO_GPRS_RLCMAC_GMMRR_ASSIGN | Req */ struct { uint32_t new_tlli; + uint32_t ptmsi; + char imsi[OSMO_IMSI_BUF_SIZE]; } assign_req; /* OSMO_GPRS_RLCMAC_GMMRR_PAGE | Ind */ struct { diff --git a/src/gmm/gmm.c b/src/gmm/gmm.c index f59147b..141ef79 100644 --- a/src/gmm/gmm.c +++ b/src/gmm/gmm.c @@ -459,6 +459,8 @@ static int gprs_gmm_submit_gmmrr_assing_req(struct gprs_gmm_entity *gmme) int rc; gmm_prim_tx = gprs_gmm_prim_alloc_gmmrr_assign_req(gmme->old_tlli, gmme->tlli); + gmm_prim_tx->gmmrr.assign_req.ptmsi = gmme->ptmsi; + OSMO_STRLCPY_ARRAY(gmm_prim_tx->gmmrr.assign_req.imsi, gmme->imsi); rc = gprs_gmm_prim_call_down_cb(gmm_prim_tx); return rc; diff --git a/src/rlcmac/gre.c b/src/rlcmac/gre.c index fe18a43..e728695 100644 --- a/src/rlcmac/gre.c +++ b/src/rlcmac/gre.c @@ -56,6 +56,7 @@ struct gprs_rlcmac_entity *gprs_rlcmac_entity_alloc(uint32_t tlli) goto err_free_gre; gre->tlli = tlli; + gre->ptmsi = GSM_RESERVED_TMSI; llist_add_tail(&gre->entry, &g_rlcmac_ctx->gre_list); return gre; diff --git a/src/rlcmac/rlcmac_prim.c b/src/rlcmac/rlcmac_prim.c index 7337647..6e2285b 100644 --- a/src/rlcmac/rlcmac_prim.c +++ b/src/rlcmac/rlcmac_prim.c @@ -426,6 +426,8 @@ static int rlcmac_prim_handle_gmmrr_assign_req(struct osmo_gprs_rlcmac_prim *rlc goto free_ret; } gprs_rlcmac_entity_free(gre); + gre = NULL; + goto free_ret; } else { /* Case "update", both old_tlli and new_tlli are valid */ gre = gprs_rlcmac_find_entity_by_tlli(old_tlli); @@ -438,6 +440,11 @@ static int rlcmac_prim_handle_gmmrr_assign_req(struct osmo_gprs_rlcmac_prim *rlc gre->tlli = new_tlli; } + /* cache/update knowledge about this GMME's PTMSI and IMSI. It will be + * needed later on to match paging requests: */ + gre->ptmsi = rlcmac_prim->gmmrr.assign_req.ptmsi; + OSMO_STRLCPY_ARRAY(gre->imsi, rlcmac_prim->gmmrr.assign_req.imsi); + free_ret: msgb_free(rlcmac_prim->oph.msg); return rc; diff --git a/tests/rlcmac/rlcmac_prim_test.c b/tests/rlcmac/rlcmac_prim_test.c index 5633da2..6213a04 100644 --- a/tests/rlcmac/rlcmac_prim_test.c +++ b/tests/rlcmac/rlcmac_prim_test.c @@ -904,6 +904,8 @@ static void test_dl_tbf_ccch_assign(void) printf("=== %s start ===\n", __func__); prepare_test(); + uint32_t ptmsi = 0x00001234; + char *imsi = "1234567890"; uint32_t tlli = 0x0000001; uint8_t ts_nr = 7; uint8_t usf = 0; @@ -913,6 +915,8 @@ static void test_dl_tbf_ccch_assign(void) /* Notify RLCMAC about our TLLI */ rlcmac_prim = osmo_gprs_rlcmac_prim_alloc_gmmrr_assign_req(GPRS_RLCMAC_TLLI_UNASSIGNED, tlli); + rlcmac_prim->gmmrr.assign_req.ptmsi = ptmsi; + OSMO_STRLCPY_ARRAY(rlcmac_prim->gmmrr.assign_req.imsi, imsi); rc = osmo_gprs_rlcmac_prim_upper_down(rlcmac_prim); OSMO_ASSERT(sizeof(ccch_imm_ass_pkt_dl_tbf) == GSM_MACBLOCK_LEN); @@ -951,6 +955,8 @@ static void test_dl_tbf_ccch_assign_requests_ul_tbf_pacch(void) printf("=== %s start ===\n", __func__); prepare_test(); RlcMacDownlink_t dl_block; + uint32_t ptmsi = 0x00001234; + char *imsi = "1234567890"; uint32_t tlli = 0x0000001; uint8_t ts_nr = 7; uint8_t usf = 0; @@ -963,6 +969,8 @@ static void test_dl_tbf_ccch_assign_requests_ul_tbf_pacch(void) /* Notify RLCMAC about our TLLI */ rlcmac_prim = osmo_gprs_rlcmac_prim_alloc_gmmrr_assign_req(GPRS_RLCMAC_TLLI_UNASSIGNED, tlli); + rlcmac_prim->gmmrr.assign_req.ptmsi = ptmsi; + OSMO_STRLCPY_ARRAY(rlcmac_prim->gmmrr.assign_req.imsi, imsi); rc = osmo_gprs_rlcmac_prim_upper_down(rlcmac_prim); OSMO_ASSERT(sizeof(ccch_imm_ass_pkt_dl_tbf) == GSM_MACBLOCK_LEN);