pespin has uploaded this change for review.

View Change

Introduce hashtable to lookup bts by CI

Change-Id: Ia9d6a38496609fc906cc78124929e594e6a9d06e
---
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/net_init.c
M src/osmo-bsc/osmo_bsc_bssap.c
6 files changed, 11 insertions(+), 2 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/26/38126/1
diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h
index 9e70ee5..308c5b9 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_ci. */
+ struct hlist_node node_by_ci;

/* 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 1dda9ae..98414d0 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -989,6 +989,7 @@
struct llist_head bts_rejected;
DECLARE_HASHTABLE(bts_by_nr, 10);
DECLARE_HASHTABLE(bts_by_lac, 10);
+ DECLARE_HASHTABLE(bts_by_ci, 10);

/* 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 d928a4b..9e31167 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_ci);

paging_destructor(bts);
bts_setup_ramp_remove(bts);
@@ -208,6 +209,8 @@

/* Default bts->location_area_code == GSM_LAC_RESERVED_DETACHED, don't add to hashtable: */
INIT_HLIST_NODE(&bts->node_by_lac);
+ /* Default CI = 0: */
+ hash_add(net->bts_by_ci, &bts->node_by_ci, bts->cell_identity);

bts->num_trx = 0;
INIT_LLIST_HEAD(&bts->trx_list);
diff --git a/src/osmo-bsc/bts_vty.c b/src/osmo-bsc/bts_vty.c
index 4ef582f..d439d72 100644
--- a/src/osmo-bsc/bts_vty.c
+++ b/src/osmo-bsc/bts_vty.c
@@ -258,7 +258,7 @@
cfg_bts_ci_cmd,
X(BSC_VTY_ATTR_RESTART_ABIS_RSL_LINK),
"cell_identity <0-65535>",
- "Set the Cell identity of this BTS\n" "Cell Identity\n")
+ "Set the Cell identity of this BTS\n" "Cell Identity (default 0)\n")
{
struct gsm_bts *bts = vty->index;
int ci = atoi(argv[0]);
@@ -269,6 +269,8 @@
return CMD_WARNING;
}
bts->cell_identity = ci;
+ hash_del(&bts->node_by_ci);
+ hash_add(bts->network->bts_by_ci, &bts->node_by_ci, bts->cell_identity);

return CMD_SUCCESS;
}
diff --git a/src/osmo-bsc/net_init.c b/src/osmo-bsc/net_init.c
index 62b3ee4..79afdc8 100644
--- a/src/osmo-bsc/net_init.c
+++ b/src/osmo-bsc/net_init.c
@@ -126,6 +126,7 @@
net->num_bts = 0;
hash_init(net->bts_by_nr);
hash_init(net->bts_by_lac);
+ hash_init(net->bts_by_ci);

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 82bdeb7..869a31b 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -201,7 +201,7 @@
uint16_t ci = params->cil.id_list[i].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_ci, bts, node_by_ci, ci) {
if (bts->cell_identity != ci)
continue;
page_subscriber(params, bts, GSM_LAC_RESERVED_ALL_BTS);

To view, visit change 38126. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ia9d6a38496609fc906cc78124929e594e6a9d06e
Gerrit-Change-Number: 38126
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>