Change in osmo-bsc[master]: Fix neigh resolution service on local neighbours

2021-02-13 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/22814 )

Change subject: Fix neigh resolution service on local neighbours
..

Fix neigh resolution service on local neighbours

Change-Id: I217e3550aa6d7f3c3cab4e545641d790ae12b23f
Related: SYS#4909
---
M src/osmo-bsc/neighbor_ident.c
M tests/ctrl/osmo-bsc-neigh-test.cfg
M tests/ctrl_test_runner.py
3 files changed, 109 insertions(+), 6 deletions(-)

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



diff --git a/src/osmo-bsc/neighbor_ident.c b/src/osmo-bsc/neighbor_ident.c
index 335091e..3235508 100644
--- a/src/osmo-bsc/neighbor_ident.c
+++ b/src/osmo-bsc/neighbor_ident.c
@@ -276,6 +276,19 @@

 CTRL_CMD_DEFINE_RO(neighbor_resolve_cgi_ps_from_lac_ci, 
"neighbor_resolve_cgi_ps_from_lac_ci");

+static int gsm_bts_get_cgi_ps(const struct gsm_bts *bts, struct 
osmo_cell_global_id_ps *cgi_ps)
+{
+   if (bts->gprs.mode == BTS_GPRS_NONE)
+   return -ENOTSUP;
+
+   cgi_ps->rai.lac.plmn = bts->network->plmn;
+   cgi_ps->rai.lac.lac = bts->location_area_code;
+   cgi_ps->rai.rac = bts->gprs.rac;
+   cgi_ps->cell_identity = bts->cell_identity;
+
+   return 0;
+}
+
 static int get_neighbor_resolve_cgi_ps_from_lac_ci(struct ctrl_cmd *cmd, void 
*data)
 {
struct gsm_network *net = (struct gsm_network *)data;
@@ -284,7 +297,9 @@
char *tmp = NULL, *tok, *saveptr;
struct neighbor_ident_key ni;
unsigned lac, cell_id;
-   const struct osmo_cell_global_id_ps *cgi_ps;
+   struct osmo_cell_global_id_ps local_cgi_ps;
+   const struct osmo_cell_global_id_ps *cgi_ps = NULL;
+   struct gsm_bts_ref *neigh;

if (!cmd->variable)
goto fmt_err;
@@ -335,10 +350,26 @@
if (!neighbor_ident_key_valid())
goto fmt_err;

-   tgt_cell_li = neighbor_ident_get(net->neighbor_bss_cells, );
-   if (!tgt_cell_li || tgt_cell_li->id_discr != CELL_IDENT_WHOLE_GLOBAL_PS 
|| tgt_cell_li->id_list_len < 1)
-   goto notfound_err;
-   cgi_ps = _cell_li->id_list[0].global_ps;
+   /* Is there a local BTS that matches the key? */
+   llist_for_each_entry(neigh, _found->local_neighbors, entry) {
+   struct gsm_bts *neigh_bts = neigh->bts;
+   struct neighbor_ident_key *neigh_bts_key = 
bts_ident_key(neigh_bts);
+   neigh_bts_key->from_bts = ni.from_bts;
+   if (!neighbor_ident_key_match(neigh_bts_key, , true))
+   continue;
+   if (gsm_bts_get_cgi_ps(neigh->bts, _cgi_ps) < 0)
+   continue; /* Not supporting GPRS */
+   cgi_ps = _cgi_ps;
+   break;
+   }
+
+   /* No local neighbor found, looking for remote neighbors */
+   if (!cgi_ps) {
+   tgt_cell_li = neighbor_ident_get(net->neighbor_bss_cells, );
+   if (!tgt_cell_li || tgt_cell_li->id_discr != 
CELL_IDENT_WHOLE_GLOBAL_PS || tgt_cell_li->id_list_len < 1)
+   goto notfound_err;
+   cgi_ps = _cell_li->id_list[0].global_ps;
+   }

ctrl_cmd_reply_printf(cmd, "%s", osmo_cgi_ps_name(cgi_ps));
talloc_free(tmp);
diff --git a/tests/ctrl/osmo-bsc-neigh-test.cfg 
b/tests/ctrl/osmo-bsc-neigh-test.cfg
index f1e71b6..2fbc8f8 100644
--- a/tests/ctrl/osmo-bsc-neigh-test.cfg
+++ b/tests/ctrl/osmo-bsc-neigh-test.cfg
@@ -46,6 +46,8 @@
   oml ipa stream-id 255 line 0
   codec-support fr
   gprs mode gprs
+  gprs routing area 5
+  ! remote neigh:
   neighbor cgi-ps 23 42 423 2 5 arfcn 23 bsic 32
   trx 0
rf_locked 0
@@ -78,6 +80,63 @@
timeslot 7
 phys_chan_config TCH/F
 hopping enabled 0
+ bts 1
+  type sysmobts
+  band DCS1800
+  cell_identity 123
+  location_area_code 1
+  base_station_id_code 55
+  ms max power 15
+  cell reselection hysteresis 4
+  rxlev access min 0
+  radio-link-timeout 32
+  channel allocator ascending
+  rach tx integer 9
+  rach max transmission 7
+  channel-description attach 1
+  channel-description bs-pa-mfrms 5
+  channel-description bs-ag-blks-res 1
+  early-classmark-sending forbidden
+  ipa unit-id 55 0
+  oml ipa stream-id 255 line 0
+  codec-support fr
+  gprs mode gprs
+  gprs routing area 6
+  neighbor bts 0
+  trx 0
+   rf_locked 0
+   arfcn 880
+   nominal power 23
+   ! to use full TRX power, set max_power_red 0
+   max_power_red 20
+   rsl e1 tei 0
+   timeslot 0
+phys_chan_config CCCH+SDCCH4
+hopping enabled 0
+   timeslot 1
+phys_chan_config TCH/F
+hopping enabled 0
+   timeslot 2
+phys_chan_config TCH/F
+hopping enabled 0
+   timeslot 3
+phys_chan_config TCH/F
+hopping enabled 0
+   timeslot 4
+phys_chan_config TCH/F
+hopping enabled 0
+   timeslot 5
+phys_chan_config TCH/F
+hopping enabled 0
+   timeslot 6
+

Change in osmo-bsc[master]: Fix neigh resolution service on local neighbours

2021-02-13 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/22814 )

Change subject: Fix neigh resolution service on local neighbours
..


Patch Set 2: Code-Review+2

(1 comment)

https://gerrit.osmocom.org/c/osmo-bsc/+/22814/2/src/osmo-bsc/neighbor_ident.c
File src/osmo-bsc/neighbor_ident.c:

https://gerrit.osmocom.org/c/osmo-bsc/+/22814/2/src/osmo-bsc/neighbor_ident.c@361
PS2, Line 361:  c
interesting situation.  And indeed, it can happen, as the neighbor cell search 
will report any cell, without knowing if it's GPRS capable or not.



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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I217e3550aa6d7f3c3cab4e545641d790ae12b23f
Gerrit-Change-Number: 22814
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 13 Feb 2021 08:14:59 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-bsc[master]: Fix neigh resolution service on local neighbours

2021-02-12 Thread daniel
daniel has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/22814 )

Change subject: Fix neigh resolution service on local neighbours
..


Patch Set 2: Code-Review+1


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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I217e3550aa6d7f3c3cab4e545641d790ae12b23f
Gerrit-Change-Number: 22814
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Fri, 12 Feb 2021 13:47:47 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-bsc[master]: Fix neigh resolution service on local neighbours

2021-02-11 Thread pespin
Hello Jenkins Builder, laforge,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-bsc/+/22814

to look at the new patch set (#2).

Change subject: Fix neigh resolution service on local neighbours
..

Fix neigh resolution service on local neighbours

Change-Id: I217e3550aa6d7f3c3cab4e545641d790ae12b23f
Related: SYS#4909
---
M src/osmo-bsc/neighbor_ident.c
M tests/ctrl/osmo-bsc-neigh-test.cfg
M tests/ctrl_test_runner.py
3 files changed, 109 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/14/22814/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/22814
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I217e3550aa6d7f3c3cab4e545641d790ae12b23f
Gerrit-Change-Number: 22814
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: newpatchset


Change in osmo-bsc[master]: Fix neigh resolution service on local neighbours

2021-02-10 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/22814 )

Change subject: Fix neigh resolution service on local neighbours
..


Patch Set 1: Code-Review+1


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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I217e3550aa6d7f3c3cab4e545641d790ae12b23f
Gerrit-Change-Number: 22814
Gerrit-PatchSet: 1
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Wed, 10 Feb 2021 16:42:17 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-bsc[master]: Fix neigh resolution service on local neighbours

2021-02-10 Thread pespin
pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/22814 )


Change subject: Fix neigh resolution service on local neighbours
..

Fix neigh resolution service on local neighbours

Change-Id: I217e3550aa6d7f3c3cab4e545641d790ae12b23f
Related: SYS#4909
---
M include/osmocom/bsc/bts.h
M src/osmo-bsc/bts.c
M src/osmo-bsc/neighbor_ident.c
M tests/ctrl/osmo-bsc-neigh-test.cfg
M tests/ctrl_test_runner.py
5 files changed, 110 insertions(+), 6 deletions(-)



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

diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h
index e1dd403..7d71991 100644
--- a/include/osmocom/bsc/bts.h
+++ b/include/osmocom/bsc/bts.h
@@ -660,3 +660,4 @@
 const char *btsvariant2str(enum gsm_bts_type_variant v);

 struct neighbor_ident_key *bts_ident_key(const struct gsm_bts *bts);
+int gsm_bts_get_cgi_ps(const struct gsm_bts *bts, struct 
osmo_cell_global_id_ps *cgi_ps);
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index 76da136..af22561 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -769,6 +769,19 @@
return 
 }

+int gsm_bts_get_cgi_ps(const struct gsm_bts *bts, struct 
osmo_cell_global_id_ps *cgi_ps)
+{
+   if (bts->gprs.mode == BTS_GPRS_NONE)
+   return -ENOTSUP;
+
+   cgi_ps->rai.lac.plmn = bts->network->plmn;
+   cgi_ps->rai.lac.lac = bts->location_area_code;
+   cgi_ps->rai.rac = bts->gprs.rac;
+   cgi_ps->cell_identity = bts->cell_identity;
+
+   return 0;
+}
+
 const struct rate_ctr_desc bts_ctr_description[] = {
[BTS_CTR_CHREQ_TOTAL] = \
{ "chreq:total",
diff --git a/src/osmo-bsc/neighbor_ident.c b/src/osmo-bsc/neighbor_ident.c
index 185cd0b..6f96033 100644
--- a/src/osmo-bsc/neighbor_ident.c
+++ b/src/osmo-bsc/neighbor_ident.c
@@ -273,7 +273,9 @@
char *tmp = NULL, *tok, *saveptr;
struct neighbor_ident_key ni;
unsigned lac, cell_id;
-   const struct osmo_cell_global_id_ps *cgi_ps;
+   struct osmo_cell_global_id_ps local_cgi_ps;
+   const struct osmo_cell_global_id_ps *cgi_ps = NULL;
+   struct gsm_bts_ref *neigh;

if (!cmd->variable)
goto fmt_err;
@@ -324,10 +326,26 @@
if (!neighbor_ident_key_valid())
goto fmt_err;

-   tgt_cell_li = neighbor_ident_get(net->neighbor_bss_cells, );
-   if (!tgt_cell_li || tgt_cell_li->id_discr != CELL_IDENT_WHOLE_GLOBAL_PS 
|| tgt_cell_li->id_list_len < 1)
-   goto notfound_err;
-   cgi_ps = _cell_li->id_list[0].global_ps;
+   /* Is there a local BTS that matches the key? */
+   llist_for_each_entry(neigh, _found->local_neighbors, entry) {
+   struct gsm_bts *neigh_bts = neigh->bts;
+   struct neighbor_ident_key *neigh_bts_key = 
bts_ident_key(neigh_bts);
+   neigh_bts_key->from_bts = ni.from_bts;
+   if (!neighbor_ident_key_match(neigh_bts_key, , true))
+   continue;
+   if (gsm_bts_get_cgi_ps(neigh->bts, _cgi_ps) < 0)
+   continue; /* Not supporting GPRS */
+   cgi_ps = _cgi_ps;
+   break;
+   }
+
+   /* No local neighbor found, looking for remote neighbors */
+   if (!cgi_ps) {
+   tgt_cell_li = neighbor_ident_get(net->neighbor_bss_cells, );
+   if (!tgt_cell_li || tgt_cell_li->id_discr != 
CELL_IDENT_WHOLE_GLOBAL_PS || tgt_cell_li->id_list_len < 1)
+   goto notfound_err;
+   cgi_ps = _cell_li->id_list[0].global_ps;
+   }

ctrl_cmd_reply_printf(cmd, "%s", osmo_cgi_ps_name(cgi_ps));
talloc_free(tmp);
diff --git a/tests/ctrl/osmo-bsc-neigh-test.cfg 
b/tests/ctrl/osmo-bsc-neigh-test.cfg
index f1e71b6..2fbc8f8 100644
--- a/tests/ctrl/osmo-bsc-neigh-test.cfg
+++ b/tests/ctrl/osmo-bsc-neigh-test.cfg
@@ -46,6 +46,8 @@
   oml ipa stream-id 255 line 0
   codec-support fr
   gprs mode gprs
+  gprs routing area 5
+  ! remote neigh:
   neighbor cgi-ps 23 42 423 2 5 arfcn 23 bsic 32
   trx 0
rf_locked 0
@@ -78,6 +80,63 @@
timeslot 7
 phys_chan_config TCH/F
 hopping enabled 0
+ bts 1
+  type sysmobts
+  band DCS1800
+  cell_identity 123
+  location_area_code 1
+  base_station_id_code 55
+  ms max power 15
+  cell reselection hysteresis 4
+  rxlev access min 0
+  radio-link-timeout 32
+  channel allocator ascending
+  rach tx integer 9
+  rach max transmission 7
+  channel-description attach 1
+  channel-description bs-pa-mfrms 5
+  channel-description bs-ag-blks-res 1
+  early-classmark-sending forbidden
+  ipa unit-id 55 0
+  oml ipa stream-id 255 line 0
+  codec-support fr
+  gprs mode gprs
+  gprs routing area 6
+  neighbor bts 0
+  trx 0
+   rf_locked 0
+   arfcn 880
+   nominal power 23
+   ! to use full TRX power, set max_power_red 0
+   max_power_red 20
+   rsl e1 tei 0
+   timeslot 0
+