pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/32345 )

Change subject: bts: Rename bts_ms_by_{tlli,imsi} -> bts_get_ms_by_{tlli,imsi}
......................................................................

bts: Rename bts_ms_by_{tlli,imsi} -> bts_get_ms_by_{tlli,imsi}

While at it, put them together and mark bts param as const.
This is a preparation for next patch.

Change-Id: Iad8aec4424f1f23cd4d02a14c4f9ec1b9fdb1f75
---
M src/bts.cpp
M src/bts.h
M src/gprs_bssgp_pcu.c
M src/gprs_ms.c
M src/pcu_l1_if.cpp
M src/pdch.cpp
M tests/alloc/AllocTest.cpp
M tests/tbf/TbfTest.cpp
8 files changed, 53 insertions(+), 41 deletions(-)

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




diff --git a/src/bts.cpp b/src/bts.cpp
index 30450bc..e3a5eeb 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -724,7 +724,7 @@
        }

        /* Find related TBF and send confirmation signal to FSM */
-       ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
        if (!ms) {
                LOGP(DTBFDL, LOGL_ERROR, "FN=%u Got IMM.ASS confirm for unknown 
MS with TLLI=%08x\n", fn, tlli);
                return -EINVAL;
@@ -1212,11 +1212,16 @@
        return bts->ms_store;
 }

-struct GprsMs *bts_ms_by_tlli(struct gprs_rlcmac_bts *bts, uint32_t tlli, 
uint32_t old_tlli)
+struct GprsMs *bts_get_ms_by_tlli(const struct gprs_rlcmac_bts *bts, uint32_t 
tlli, uint32_t old_tlli)
 {
        return bts_ms_store(bts)->get_ms(tlli, old_tlli);
 }

+struct GprsMs *bts_get_ms_by_imsi(const struct gprs_rlcmac_bts *bts, const 
char *imsi)
+{
+       return bts_ms_store(bts)->get_ms(GSM_RESERVED_TMSI, GSM_RESERVED_TMSI, 
imsi);
+}
+
 /* update TA based on TA provided by PH-DATA-IND */
 void update_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, int8_t ta_delta)
 {
@@ -1422,11 +1427,6 @@
        bts_set_max_mcs_ul(bts, mcs_ul);
 }

-struct GprsMs *bts_ms_by_imsi(struct gprs_rlcmac_bts *bts, const char *imsi)
-{
-       return bts_ms_store(bts)->get_ms(GSM_RESERVED_TMSI, GSM_RESERVED_TMSI, 
imsi);
-}
-
 const struct llist_head* bts_ms_list(struct gprs_rlcmac_bts *bts)
 {
        return bts_ms_store(bts)->ms_list();
diff --git a/src/bts.h b/src/bts.h
index a1ea796..7f6be73 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -331,7 +331,8 @@

 struct GprsMsStorage *bts_ms_store(const struct gprs_rlcmac_bts *bts);

-struct GprsMs *bts_ms_by_tlli(struct gprs_rlcmac_bts *bts, uint32_t tlli, 
uint32_t old_tlli);
+struct GprsMs *bts_get_ms_by_tlli(const struct gprs_rlcmac_bts *bts, uint32_t 
tlli, uint32_t old_tlli);
+struct GprsMs *bts_get_ms_by_imsi(const struct gprs_rlcmac_bts *bts, const 
char *imsi);

 static inline struct rate_ctr_group *bts_rate_counters(struct gprs_rlcmac_bts 
*bts)
 {
@@ -369,7 +370,6 @@
 void bts_recalc_initial_mcs(struct gprs_rlcmac_bts *bts);
 void bts_recalc_max_cs(struct gprs_rlcmac_bts *bts);
 void bts_recalc_max_mcs(struct gprs_rlcmac_bts *bts);
-struct GprsMs *bts_ms_by_imsi(struct gprs_rlcmac_bts *bts, const char *imsi);
 uint8_t bts_max_cs_dl(const struct gprs_rlcmac_bts *bts);
 uint8_t bts_max_cs_ul(const struct gprs_rlcmac_bts *bts);
 uint8_t bts_max_mcs_dl(const struct gprs_rlcmac_bts *bts);
diff --git a/src/gprs_bssgp_pcu.c b/src/gprs_bssgp_pcu.c
index 656342e..2c5a97a 100644
--- a/src/gprs_bssgp_pcu.c
+++ b/src/gprs_bssgp_pcu.c
@@ -244,9 +244,9 @@
         * target MS is using. */
        llist_for_each_entry(bts, &the_pcu->bts_list, list) {
                /* TODO: Match by TMSI before IMSI if present?! */
-               ms = bts_ms_by_tlli(bts, req.tlli, req.tlli);
+               ms = bts_get_ms_by_tlli(bts, req.tlli, req.tlli);
                if (!ms && req.mi_imsi_present)
-                       ms = bts_ms_by_imsi(bts, req.mi_imsi.imsi);
+                       ms = bts_get_ms_by_imsi(bts, req.mi_imsi.imsi);
                bts_add_paging(bts, &req, ms);
        }

diff --git a/src/gprs_ms.c b/src/gprs_ms.c
index 9ce3d82..909e7f8 100644
--- a/src/gprs_ms.c
+++ b/src/gprs_ms.c
@@ -558,7 +558,7 @@
                "Modifying MS object, TLLI = 0x%08x, IMSI '%s' -> '%s'\n",
                ms_tlli(ms), ms->imsi, imsi);

-       struct GprsMs *old_ms = bts_ms_by_imsi(ms->bts, imsi);
+       struct GprsMs *old_ms = bts_get_ms_by_imsi(ms->bts, imsi);
        /* Check if we are going to store a different MS object with already
           existing IMSI. This is probably a bug in code calling this function,
           since it should take care of this explicitly */
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 577ba57..7068083 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -1071,7 +1071,7 @@
        case GSM_MI_TYPE_IMSI:
                req.mi_imsi = mi;
                req.mi_imsi_present = true;
-               ms = bts_ms_by_imsi(bts, req.mi_imsi.imsi);
+               ms = bts_get_ms_by_imsi(bts, req.mi_imsi.imsi);
                break;
        default:
                LOGP(DL1IF, LOGL_ERROR, "Unexpected MI type %u\n", mi.type);
diff --git a/src/pdch.cpp b/src/pdch.cpp
index e397a8f..081c306 100644
--- a/src/pdch.cpp
+++ b/src/pdch.cpp
@@ -348,7 +348,7 @@
                LOGPDCH(this, DRLCMAC, LOGL_NOTICE, "PACKET CONTROL ACK with "
                        "unknown FN=%u TLLI=0x%08x (TRX %d TS %d)\n",
                        fn, tlli, trx_no(), ts_no);
-               ms = bts_ms_by_tlli(bts(), tlli, GSM_RESERVED_TMSI);
+               ms = bts_get_ms_by_tlli(bts(), tlli, GSM_RESERVED_TMSI);
                if (ms)
                        LOGPDCH(this, DRLCMAC, LOGL_NOTICE, "PACKET CONTROL ACK 
with "
                                "unknown TBF corresponds to MS with IMSI %s, TA 
%d, "
@@ -664,7 +664,7 @@
        /* First gather MS from TLLI/DL_TFI/UL_TFI:*/
        if (request->ID.UnionType) { /* ID_TYPE = TLLI */
                uint32_t tlli = request->ID.u.TLLI;
-               ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+               ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
                if (!ms) {
                        ms = bts_alloc_ms(bts);
                        ms_set_tlli(ms, tlli);
@@ -854,7 +854,7 @@
        struct pdch_ulc_node *poll;
        GprsMs *ms;
 
-       ms = bts_ms_by_tlli(bts(), report->TLLI, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts(), report->TLLI, GSM_RESERVED_TMSI);
        if (!ms) {
                LOGPDCH(this, DRLCMAC, LOGL_NOTICE, "MS send measurement "
                        "but TLLI 0x%08x is unknown\n", report->TLLI);
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index 3282268..4497fbd 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -559,7 +559,7 @@
                enum gprs_rlcmac_tbf_direction dir;
                uint32_t tlli = counter + 0xc0000000;

-               ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+               ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
                if (!ms)
                        ms = bts_alloc_ms(bts);
                ms_set_ms_class(ms, ms_class);
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index 63074d0..42b6d29 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -139,7 +139,7 @@
        OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
        OSMO_ASSERT(ul_tbf->ms() == ms);

-       OSMO_ASSERT(bts_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI) == ms);
+       OSMO_ASSERT(bts_get_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI) == ms);

        /*
         * Now check.. that DL changes and that the timing advance
@@ -148,20 +148,20 @@
        ms_confirm_tlli(dl_tbf->ms(), 0x4232);

        /* It is still there, since the new TLLI has not been used for UL yet */
-       ms_new = bts_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI);
+       ms_new = bts_get_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms == ms_new);

-       ms_new = bts_ms_by_tlli(bts, 0x4232, GSM_RESERVED_TMSI);
+       ms_new = bts_get_ms_by_tlli(bts, 0x4232, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms == ms_new);
        OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf);
        OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);

        /* Now use the new TLLI for UL */
        ms_update_announced_tlli(ms, 0x4232);
-       ms_new = bts_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI);
+       ms_new = bts_get_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms_new == NULL);

-       ms_new = bts_ms_by_tlli(bts, 0x4232, GSM_RESERVED_TMSI);
+       ms_new = bts_get_ms_by_tlli(bts, 0x4232, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms_new != NULL);
        OSMO_ASSERT(ms_ta(ms_new) == 4);

@@ -658,7 +658,7 @@

        pdch->rcv_block(&data_msg[0], sizeof(data_msg), *fn, &meas);

-       ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms != NULL);

        return ul_tbf;
@@ -797,7 +797,7 @@

        pdch->rcv_block(&data_msg[0], 23, *fn, &meas);

-       ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms != NULL);
        OSMO_ASSERT(ms_ta(ms) == qta/4);
        OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
@@ -941,7 +941,7 @@

        pdch->rcv_block(&data_msg[0], 23, *fn, &meas);

-       ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms != NULL);
        OSMO_ASSERT(ms_ta(ms) == qta/4);
        OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
@@ -1430,7 +1430,7 @@
        check_tbf(ul_tbf);
        OSMO_ASSERT(tbf_ul_ack_fi(ul_tbf)->state == TBF_UL_ACK_ST_NONE);

-       ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms != NULL);
        OSMO_ASSERT(ms_ta(ms) == qta/4);
        OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
@@ -1511,7 +1511,7 @@
        check_tbf(ul_tbf);
        OSMO_ASSERT(tbf_ul_ack_fi(ul_tbf)->state == TBF_UL_ACK_ST_NONE);

-       ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms != NULL);
        OSMO_ASSERT(ms_ta(ms) == qta/4);
        OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
@@ -1593,7 +1593,7 @@
        check_tbf(ul_tbf);
        OSMO_ASSERT(tbf_ul_ack_fi(ul_tbf)->state == TBF_UL_ACK_ST_NONE);

-       ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms != NULL);
        OSMO_ASSERT(ms_ta(ms) == qta/4);
        OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
@@ -1670,7 +1670,7 @@

        pdch->rcv_block(&data_msg[0], sizeof(data_msg), *fn, &meas);

-       ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms != NULL);
        OSMO_ASSERT(ms_ta(ms) == qta/4);
        OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
@@ -1688,11 +1688,11 @@
        dl_tbf_handle(bts, tlli, 0, imsi, 0, 0,
                1000, data, data_size);

-       ms = bts_ms_by_imsi(bts, imsi);
+       ms = bts_get_ms_by_imsi(bts, imsi);
        OSMO_ASSERT(ms != NULL);

        if (imsi[0] != '\0') {
-               ms2 = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+               ms2 = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
                OSMO_ASSERT(ms == ms2);
        }
 }
@@ -1704,7 +1704,7 @@
        GprsMs *ms;
        unsigned ts_no;

-       ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms);
        dl_tbf = ms_dl_tbf(ms);
        OSMO_ASSERT(dl_tbf);
@@ -2013,14 +2013,14 @@
         * the PCU can see, that both MS objects belong to same MS */
        send_dl_data(bts, tlli2, imsi, (const uint8_t *)"DATA", 4);

-       ms = bts_ms_by_imsi(bts, imsi);
+       ms = bts_get_ms_by_imsi(bts, imsi);
        OSMO_ASSERT(ms == ms2);

        print_ms(ms2, false);

-       ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms == NULL);
-       ms = bts_ms_by_tlli(bts, tlli2, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli2, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms == ms2);

        TALLOC_FREE(the_pcu);
@@ -2063,7 +2063,7 @@

        /* Get rid of old UL TBF */
        tbf_free(ul_tbf);
-       ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms1 == ms);

        /* Now establish a new UL TBF, this will consume one LLC packet */
@@ -2076,7 +2076,7 @@
        /* This should be the same MS object */
        OSMO_ASSERT(ms2 == ms1);

-       ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms2 == ms);

        /* A DL TBF should still exist */
@@ -2126,7 +2126,7 @@

        /* Get rid of old UL TBF */
        tbf_free(ul_tbf);
-       ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms1 == ms);

        /* Now establish a new UL TBF */
@@ -2138,7 +2138,7 @@
        /* There should be a different MS object */
        OSMO_ASSERT(ms2 != ms1);

-       ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms2 == ms);
        OSMO_ASSERT(ms1 != ms);

@@ -2235,7 +2235,7 @@

        request_dl_rlc_block(dl_tbf1, &fn);

-       ms2 = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI);
+       ms2 = bts_get_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms2 == ms1);
        OSMO_ASSERT(ms_dl_tbf(ms2));
        OSMO_ASSERT(ms_dl_tbf(ms2)->state_is(TBF_ST_ASSIGN));
@@ -2607,7 +2607,7 @@

        uint8_t data_msg[49] = {0};

-       ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
+       ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI);
        OSMO_ASSERT(ms != NULL);
        OSMO_ASSERT(ms_ta(ms) == qta/4);
        OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Iad8aec4424f1f23cd4d02a14c4f9ec1b9fdb1f75
Gerrit-Change-Number: 32345
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to