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
This commit is contained in:
Pau Espin Pedrol
2024-09-12 17:38:05 +02:00
parent 2045a24042
commit 15284337ec
6 changed files with 20 additions and 3 deletions

View File

@@ -345,6 +345,8 @@ struct gsm_bts {
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;

View File

@@ -989,6 +989,8 @@ struct gsm_network {
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

View File

@@ -161,6 +161,7 @@ static int gsm_bts_talloc_destructor(struct gsm_bts *bts)
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 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, struct gsm_bts_sm *bts_sm
/* 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);

View File

@@ -271,6 +271,11 @@ DEFUN_USRATTR(cfg_bts_ci,
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 @@ DEFUN_USRATTR(cfg_bts_lac,
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;
}

View File

@@ -377,7 +377,8 @@ int neighbor_address_resolution(const struct gsm_network *net, const struct cell
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)

View File

@@ -150,7 +150,8 @@ static void page_cgi(const struct bsc_paging_params *params)
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 @@ static void page_lac_and_ci(const struct bsc_paging_params *params)
const struct osmo_lac_and_ci_id *id = &params->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)