pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/38087?usp=email )


Change subject: Introduce hashtable to lookup bts by LAC
......................................................................

Introduce hashtable to lookup bts by LAC

Related: SYS#7062
Change-Id: Id523027b49e0f58cd2c8c9b4dee619de415dbd15
---
M include/osmocom/bsc/bts.h
M include/osmocom/bsc/gsm_data.h
M src/osmo-bsc/bts.c
M src/osmo-bsc/bts_vty.c
M src/osmo-bsc/neighbor_ident.c
M src/osmo-bsc/net_init.c
M src/osmo-bsc/osmo_bsc_bssap.c
7 files changed, 15 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/87/38087/1

diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h
index 8e530ef..9e70ee5 100644
--- a/include/osmocom/bsc/bts.h
+++ b/include/osmocom/bsc/bts.h
@@ -343,6 +343,8 @@

        /*! Entry in hash table network->bts_by_nr. */
        struct hlist_node node_by_nr;
+       /*! Entry in hash table network->bts_by_lac. */
+       struct hlist_node node_by_lac;

        /* number of this BTS in network */
        gsm_bts_nr_t nr;
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 008130e..a0bb3ec 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -988,6 +988,7 @@
        struct llist_head bts_list;
        struct llist_head bts_rejected;
        DECLARE_HASHTABLE(bts_by_nr, 6);
+       DECLARE_HASHTABLE(bts_by_lac, 6);

        /* BTS-based counters when we can't find the actual BTS
         * e.g. when conn->lchan is NULL */
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index 38e5f11..11aced4 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -160,6 +160,7 @@

        llist_del(&bts->list);
        hash_del(&bts->node_by_nr);
+       hash_del(&bts->node_by_lac);

        paging_destructor(bts);
        bts_setup_ramp_remove(bts);
@@ -203,6 +204,7 @@

        llist_add_tail(&bts->list, &net->bts_list);
        hash_add(net->bts_by_nr, &bts->node_by_nr, bts->nr);
+       INIT_HLIST_NODE(&bts->node_by_lac);
        net->num_bts++;

        bts->num_trx = 0;
diff --git a/src/osmo-bsc/bts_vty.c b/src/osmo-bsc/bts_vty.c
index 81c4022..4ef582f 100644
--- a/src/osmo-bsc/bts_vty.c
+++ b/src/osmo-bsc/bts_vty.c
@@ -278,8 +278,8 @@
              X(BSC_VTY_ATTR_RESTART_ABIS_RSL_LINK),
              "location_area_code (<0-65535>|<0x0000-0xffff>)",
              "Set the Location Area Code (LAC) of this BTS\n"
-             "LAC in decimal format\n"
-             "LAC in hexadecimal format\n")
+             "LAC in decimal format (default 0, reserved by GSM 04.08)\n"
+             "LAC in hexadecimal format (default 0x0000, reserved by GSM 
04.08)\n")
 {
        struct gsm_bts *bts = vty->index;
        int lac;
@@ -293,6 +293,8 @@
        }

        bts->location_area_code = lac;
+       hash_del(&bts->node_by_lac);
+       hash_add(bts->network->bts_by_lac, &bts->node_by_lac, 
bts->location_area_code);

        return CMD_SUCCESS;
 }
diff --git a/src/osmo-bsc/neighbor_ident.c b/src/osmo-bsc/neighbor_ident.c
index 3e42c5f..4d52c50 100644
--- a/src/osmo-bsc/neighbor_ident.c
+++ b/src/osmo-bsc/neighbor_ident.c
@@ -377,7 +377,7 @@
        struct gsm_bts *local_neighbor = NULL;
        struct gsm0808_cell_id_list2 remote_neighbors = { 0 };

-       llist_for_each_entry(bts_tmp, &net->bts_list, list) {
+       hash_for_each_possible(net->bts_by_lac, bts_tmp, node_by_lac, lac) {
                if (bts_tmp->location_area_code != lac)
                        continue;
                if (bts_tmp->cell_identity != cell_id)
diff --git a/src/osmo-bsc/net_init.c b/src/osmo-bsc/net_init.c
index fc29d43..62b3ee4 100644
--- a/src/osmo-bsc/net_init.c
+++ b/src/osmo-bsc/net_init.c
@@ -125,6 +125,7 @@
        INIT_LLIST_HEAD(&net->bts_list);
        net->num_bts = 0;
        hash_init(net->bts_by_nr);
+       hash_init(net->bts_by_lac);

        net->T_defs = gsm_network_T_defs;
        osmo_tdefs_reset(net->T_defs);
diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c
index c9e8e5e..82bdeb7 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -150,7 +150,7 @@
                if (!osmo_plmn_cmp(&id->lai.plmn, &bsc_gsmnet->plmn)) {
                        int paged = 0;
                        struct gsm_bts *bts;
-                       llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
+                       hash_for_each_possible(bsc_gsmnet->bts_by_lac, bts, 
node_by_lac, id->lai.lac) {
                                if (bts->location_area_code != id->lai.lac)
                                        continue;
                                if (bts->cell_identity != id->cell_identity)
@@ -179,7 +179,7 @@
                const struct osmo_lac_and_ci_id *id = 
&params->cil.id_list[i].lac_and_ci;
                int paged = 0;
                struct gsm_bts *bts;
-               llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
+               hash_for_each_possible(bsc_gsmnet->bts_by_lac, bts, 
node_by_lac, id->lac) {
                        if (bts->location_area_code != id->lac)
                                continue;
                        if (bts->cell_identity != id->ci)
@@ -222,7 +222,7 @@
                if (!osmo_plmn_cmp(&id->plmn, &bsc_gsmnet->plmn)) {
                        int paged = 0;
                        struct gsm_bts *bts;
-                       llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
+                       hash_for_each_possible(bsc_gsmnet->bts_by_lac, bts, 
node_by_lac, id->lac) {
                                if (bts->location_area_code != id->lac)
                                        continue;
                                page_subscriber(params, bts, id->lac);
@@ -248,7 +248,7 @@
                uint16_t lac = params->cil.id_list[i].lac;
                int paged = 0;
                struct gsm_bts *bts;
-               llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
+               hash_for_each_possible(bsc_gsmnet->bts_by_lac, bts, 
node_by_lac, lac) {
                        if (bts->location_area_code != lac)
                                continue;
                        page_subscriber(params, bts, lac);

--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/38087?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Id523027b49e0f58cd2c8c9b4dee619de415dbd15
Gerrit-Change-Number: 38087
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>

Reply via email to