pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/38127?usp=email )
Change subject: Introduce hashtable to lookup bts by <LAC,CI> ......................................................................
Introduce hashtable to lookup bts by <LAC,CI>
This is useful to quickly lookup pagings aiming at a LAC+CI. Until now, we first looked up in the LAC hashtable and then iterated over it. However, that means a potential configuration where all BTS share the same LAC will end up in iterating over 256 bts, which is not nice.
Change-Id: I47db6c7543e5c6c3b8f0de3ae5ee1b53c2b5f16f Related: SYS#7062 --- 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/osmo_bsc_bssap.c 6 files changed, 20 insertions(+), 3 deletions(-)
Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved
diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h index 308c5b9..251c161 100644 --- a/include/osmocom/bsc/bts.h +++ b/include/osmocom/bsc/bts.h @@ -345,6 +345,8 @@ struct hlist_node node_by_nr; /*! Entry in hash table network->bts_by_lac. */ struct hlist_node node_by_lac; + /*! Entry in hash table network->bts_by_lac_ci. */ + struct hlist_node node_by_lac_ci; /*! Entry in hash table network->bts_by_ci. */ struct hlist_node node_by_ci;
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 98414d0..59d22d7 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -989,6 +989,8 @@ struct llist_head bts_rejected; DECLARE_HASHTABLE(bts_by_nr, 10); DECLARE_HASHTABLE(bts_by_lac, 10); + DECLARE_HASHTABLE(bts_by_lac_ci, 10); +#define LAC_CI_HASHTABLE_KEY(lac, ci) ((((uint32_t)(ci)) << sizeof(lac)) | (uint32_t)(lac)) DECLARE_HASHTABLE(bts_by_ci, 10);
/* BTS-based counters when we can't find the actual BTS diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c index 9e31167..c21e5b3 100644 --- a/src/osmo-bsc/bts.c +++ b/src/osmo-bsc/bts.c @@ -161,6 +161,7 @@ llist_del(&bts->list); hash_del(&bts->node_by_nr); hash_del(&bts->node_by_lac); + hash_del(&bts->node_by_lac_ci); hash_del(&bts->node_by_ci);
paging_destructor(bts); @@ -209,6 +210,7 @@
/* Default bts->location_area_code == GSM_LAC_RESERVED_DETACHED, don't add to hashtable: */ INIT_HLIST_NODE(&bts->node_by_lac); + INIT_HLIST_NODE(&bts->node_by_lac_ci); /* Default CI = 0: */ hash_add(net->bts_by_ci, &bts->node_by_ci, bts->cell_identity);
diff --git a/src/osmo-bsc/bts_vty.c b/src/osmo-bsc/bts_vty.c index d439d72..f6ee514 100644 --- a/src/osmo-bsc/bts_vty.c +++ b/src/osmo-bsc/bts_vty.c @@ -271,6 +271,11 @@ bts->cell_identity = ci; hash_del(&bts->node_by_ci); hash_add(bts->network->bts_by_ci, &bts->node_by_ci, bts->cell_identity); + if (bts->location_area_code != GSM_LAC_RESERVED_DETACHED) { + hash_del(&bts->node_by_lac_ci); + hash_add(bts->network->bts_by_lac_ci, &bts->node_by_lac_ci, + LAC_CI_HASHTABLE_KEY(bts->location_area_code, bts->cell_identity)); + }
return CMD_SUCCESS; } @@ -296,7 +301,10 @@
bts->location_area_code = lac; hash_del(&bts->node_by_lac); + hash_del(&bts->node_by_lac_ci); hash_add(bts->network->bts_by_lac, &bts->node_by_lac, bts->location_area_code); + hash_add(bts->network->bts_by_lac_ci, &bts->node_by_lac_ci, + LAC_CI_HASHTABLE_KEY(bts->location_area_code, bts->cell_identity));
return CMD_SUCCESS; } diff --git a/src/osmo-bsc/neighbor_ident.c b/src/osmo-bsc/neighbor_ident.c index 4d52c50..6fbd4f5 100644 --- a/src/osmo-bsc/neighbor_ident.c +++ b/src/osmo-bsc/neighbor_ident.c @@ -377,7 +377,8 @@ struct gsm_bts *local_neighbor = NULL; struct gsm0808_cell_id_list2 remote_neighbors = { 0 };
- hash_for_each_possible(net->bts_by_lac, bts_tmp, node_by_lac, lac) { + hash_for_each_possible(net->bts_by_lac_ci, bts_tmp, node_by_lac_ci, + LAC_CI_HASHTABLE_KEY(lac, cell_id)) { if (bts_tmp->location_area_code != lac) continue; if (bts_tmp->cell_identity != cell_id) diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c index 869a31b..6299279 100644 --- a/src/osmo-bsc/osmo_bsc_bssap.c +++ b/src/osmo-bsc/osmo_bsc_bssap.c @@ -150,7 +150,8 @@ if (!osmo_plmn_cmp(&id->lai.plmn, &bsc_gsmnet->plmn)) { int paged = 0; struct gsm_bts *bts; - hash_for_each_possible(bsc_gsmnet->bts_by_lac, bts, node_by_lac, id->lai.lac) { + hash_for_each_possible(bsc_gsmnet->bts_by_lac_ci, bts, node_by_lac_ci, + LAC_CI_HASHTABLE_KEY(id->lai.lac, id->cell_identity)) { if (bts->location_area_code != id->lai.lac) continue; if (bts->cell_identity != id->cell_identity) @@ -179,7 +180,8 @@ const struct osmo_lac_and_ci_id *id = ¶ms->cil.id_list[i].lac_and_ci; int paged = 0; struct gsm_bts *bts; - hash_for_each_possible(bsc_gsmnet->bts_by_lac, bts, node_by_lac, id->lac) { + hash_for_each_possible(bsc_gsmnet->bts_by_lac_ci, bts, node_by_lac_ci, + LAC_CI_HASHTABLE_KEY(id->lac, id->ci)) { if (bts->location_area_code != id->lac) continue; if (bts->cell_identity != id->ci)