aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-12-01 17:25:28 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2020-12-03 16:31:36 +0100
commit64c422858db9388e210875dc681f2d1952e0d0bb (patch)
tree85d8baa6526562e89c9912d3da76507e0ce4fba3 /src
parent8c03bf3f3c58afa582ed000ba05e886b593256f9 (diff)
Store GPRS MOs directly under BTS SiteMgr object
The only real 1-1 relationship between BTS NM objects is the one between GPRS Cell and BTS (which is actually a BTS cell). In our current osmo-bts implementation we don't care much since we only handle 1-cell BTSses, but let's make the data structure organization more generic. Implementation notes: The gsm_bts_sm is moved to its own file, APIs to allocate are added and the new public object is hooked correctly in the allocation process of osmo-bsc. Change-Id: I06461b7784fa2a78de37383406e35beae85fbad8
Diffstat (limited to 'src')
-rw-r--r--src/ipaccess/Makefile.am2
-rw-r--r--src/osmo-bsc/Makefile.am1
-rw-r--r--src/osmo-bsc/abis_nm.c6
-rw-r--r--src/osmo-bsc/bsc_vty.c39
-rw-r--r--src/osmo-bsc/bts.c29
-rw-r--r--src/osmo-bsc/bts_ipaccess_nanobts.c13
-rw-r--r--src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c28
-rw-r--r--src/osmo-bsc/bts_nokia_site.c2
-rw-r--r--src/osmo-bsc/bts_sm.c85
-rw-r--r--src/osmo-bsc/gsm_data.c22
-rw-r--r--src/osmo-bsc/nm_bb_transc_fsm.c4
-rw-r--r--src/osmo-bsc/nm_bts_fsm.c4
-rw-r--r--src/osmo-bsc/nm_bts_sm_fsm.c2
-rw-r--r--src/osmo-bsc/nm_channel_fsm.c4
-rw-r--r--src/osmo-bsc/osmo_bsc_main.c4
-rw-r--r--src/osmo-bsc/pcu_sock.c13
-rw-r--r--src/utils/Makefile.am2
17 files changed, 170 insertions, 90 deletions
diff --git a/src/ipaccess/Makefile.am b/src/ipaccess/Makefile.am
index 1574a8b94..c489e0a90 100644
--- a/src/ipaccess/Makefile.am
+++ b/src/ipaccess/Makefile.am
@@ -47,6 +47,7 @@ ipaccess_config_SOURCES = \
# FIXME: resolve the bogus dependencies patched around here:
ipaccess_config_LDADD = \
$(top_builddir)/src/osmo-bsc/bts.o \
+ $(top_builddir)/src/osmo-bsc/bts_sm.o \
$(top_builddir)/src/osmo-bsc/bts_trx.o \
$(top_builddir)/src/osmo-bsc/abis_nm.o \
$(top_builddir)/src/osmo-bsc/acc.o \
@@ -72,6 +73,7 @@ ipaccess_proxy_LDADD = \
$(top_builddir)/src/osmo-bsc/abis_nm.o \
$(top_builddir)/src/osmo-bsc/acc.o \
$(top_builddir)/src/osmo-bsc/bts.o \
+ $(top_builddir)/src/osmo-bsc/bts_sm.o \
$(top_builddir)/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.o \
$(top_builddir)/src/osmo-bsc/bts_trx.o \
$(top_builddir)/src/osmo-bsc/gsm_data.o \
diff --git a/src/osmo-bsc/Makefile.am b/src/osmo-bsc/Makefile.am
index 573988549..89f869d01 100644
--- a/src/osmo-bsc/Makefile.am
+++ b/src/osmo-bsc/Makefile.am
@@ -52,6 +52,7 @@ osmo_bsc_SOURCES = \
bts_ipaccess_nanobts_omlattr.c \
bts_nokia_site.c \
bts_siemens_bs11.c \
+ bts_sm.c \
bts_sysmobts.c \
bts_unknown.c \
chan_alloc.c \
diff --git a/src/osmo-bsc/abis_nm.c b/src/osmo-bsc/abis_nm.c
index 73dc2d018..657948f8a 100644
--- a/src/osmo-bsc/abis_nm.c
+++ b/src/osmo-bsc/abis_nm.c
@@ -866,11 +866,11 @@ bool all_trx_rsl_connected_unlocked(const struct gsm_bts *bts)
if (bts->gprs.cell.mo.nm_state.administrative == NM_STATE_LOCKED)
return false;
- if (bts->gprs.nse.mo.nm_state.administrative == NM_STATE_LOCKED)
+ if (bts->site_mgr->gprs.nse.mo.nm_state.administrative == NM_STATE_LOCKED)
return false;
- if (bts->gprs.nsvc[0].mo.nm_state.administrative == NM_STATE_LOCKED &&
- bts->gprs.nsvc[1].mo.nm_state.administrative == NM_STATE_LOCKED)
+ if (bts->site_mgr->gprs.nsvc[0].mo.nm_state.administrative == NM_STATE_LOCKED &&
+ bts->site_mgr->gprs.nsvc[1].mo.nm_state.administrative == NM_STATE_LOCKED)
return false;
}
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index 846339d4e..c98a25431 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -463,17 +463,17 @@ static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
vty_out(vty, " NM State: ");
net_dump_nmstate(vty, &bts->mo.nm_state);
vty_out(vty, " Site Mgr NM State: ");
- net_dump_nmstate(vty, &bts->site_mgr.mo.nm_state);
+ net_dump_nmstate(vty, &bts->site_mgr->mo.nm_state);
if (bts->gprs.mode != BTS_GPRS_NONE) {
vty_out(vty, " GPRS NSE: ");
- net_dump_nmstate(vty, &bts->gprs.nse.mo.nm_state);
+ net_dump_nmstate(vty, &bts->site_mgr->gprs.nse.mo.nm_state);
vty_out(vty, " GPRS CELL: ");
net_dump_nmstate(vty, &bts->gprs.cell.mo.nm_state);
vty_out(vty, " GPRS NSVC0: ");
- net_dump_nmstate(vty, &bts->gprs.nsvc[0].mo.nm_state);
+ net_dump_nmstate(vty, &bts->site_mgr->gprs.nsvc[0].mo.nm_state);
vty_out(vty, " GPRS NSVC1: ");
- net_dump_nmstate(vty, &bts->gprs.nsvc[1].mo.nm_state);
+ net_dump_nmstate(vty, &bts->site_mgr->gprs.nsvc[1].mo.nm_state);
} else
vty_out(vty, " GPRS: not configured%s", VTY_NEWLINE);
@@ -740,6 +740,7 @@ static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
{
unsigned int i;
+ struct gsm_bts_sm *bts_sm = bts->site_mgr;
vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
VTY_NEWLINE);
if (bts->gprs.mode == BTS_GPRS_NONE)
@@ -757,15 +758,15 @@ static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
vty_out(vty, " gprs cell timer %s %u%s",
get_value_string(gprs_bssgp_cfg_strs, i),
bts->gprs.cell.timer[i], VTY_NEWLINE);
- vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
+ vty_out(vty, " gprs nsei %u%s", bts_sm->gprs.nse.nsei,
VTY_NEWLINE);
- for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
+ for (i = 0; i < ARRAY_SIZE(bts_sm->gprs.nse.timer); i++)
vty_out(vty, " gprs ns timer %s %u%s",
get_value_string(gprs_ns_timer_strs, i),
- bts->gprs.nse.timer[i], VTY_NEWLINE);
- for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
- struct gsm_bts_gprs_nsvc *nsvc =
- &bts->gprs.nsvc[i];
+ bts_sm->gprs.nse.timer[i], VTY_NEWLINE);
+ for (i = 0; i < ARRAY_SIZE(bts_sm->gprs.nsvc); i++) {
+ struct gsm_gprs_nsvc *nsvc =
+ &bts_sm->gprs.nsvc[i];
struct osmo_sockaddr_str remote = {};
uint16_t port;
@@ -3190,7 +3191,7 @@ DEFUN_USRATTR(cfg_bts_gprs_nsei,
GPRS_CHECK_ENABLED(bts);
- bts->gprs.nse.nsei = atoi(argv[0]);
+ bts->site_mgr->gprs.nse.nsei = atoi(argv[0]);
return CMD_SUCCESS;
}
@@ -3211,7 +3212,7 @@ DEFUN_USRATTR(cfg_bts_gprs_nsvci,
GPRS_CHECK_ENABLED(bts);
- bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
+ bts->site_mgr->gprs.nsvc[idx].nsvci = atoi(argv[1]);
return CMD_SUCCESS;
}
@@ -3231,7 +3232,7 @@ DEFUN_USRATTR(cfg_bts_gprs_nsvc_lport,
GPRS_CHECK_ENABLED(bts);
- bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
+ bts->site_mgr->gprs.nsvc[idx].local_port = atoi(argv[1]);
return CMD_SUCCESS;
}
@@ -3252,7 +3253,7 @@ DEFUN_USRATTR(cfg_bts_gprs_nsvc_rport,
GPRS_CHECK_ENABLED(bts);
/* sockaddr_in and sockaddr_in6 have the port at the same position */
- bts->gprs.nsvc[idx].remote.u.sin.sin_port = htons(atoi(argv[1]));
+ bts->site_mgr->gprs.nsvc[idx].remote.u.sin.sin_port = htons(atoi(argv[1]));
return CMD_SUCCESS;
}
@@ -3281,13 +3282,13 @@ DEFUN_USRATTR(cfg_bts_gprs_nsvc_rip,
}
/* Can't use osmo_sockaddr_str_to_sockaddr() because the port would be overriden */
- bts->gprs.nsvc[idx].remote.u.sas.ss_family = remote.af;
+ bts->site_mgr->gprs.nsvc[idx].remote.u.sas.ss_family = remote.af;
switch (remote.af) {
case AF_INET:
- osmo_sockaddr_str_to_in_addr(&remote, &bts->gprs.nsvc[idx].remote.u.sin.sin_addr);
+ osmo_sockaddr_str_to_in_addr(&remote, &bts->site_mgr->gprs.nsvc[idx].remote.u.sin.sin_addr);
break;
case AF_INET6:
- osmo_sockaddr_str_to_in6_addr(&remote, &bts->gprs.nsvc[idx].remote.u.sin6.sin6_addr);
+ osmo_sockaddr_str_to_in6_addr(&remote, &bts->site_mgr->gprs.nsvc[idx].remote.u.sin6.sin6_addr);
break;
}
@@ -3321,10 +3322,10 @@ DEFUN_USRATTR(cfg_bts_gprs_ns_timer,
GPRS_CHECK_ENABLED(bts);
- if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
+ if (idx < 0 || idx >= ARRAY_SIZE(bts->site_mgr->gprs.nse.timer))
return CMD_WARNING;
- bts->gprs.nse.timer[idx] = val;
+ bts->site_mgr->gprs.nse.timer[idx] = val;
return CMD_SUCCESS;
}
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index 065b8ab67..2c6b0f1b6 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -121,7 +121,6 @@ int gsm_bts_model_register(struct gsm_bts_model *model)
return 0;
}
-static const uint8_t bts_nse_timer_default[] = { 3, 3, 3, 3, 30, 3, 10 };
static const uint8_t bts_cell_timer_default[] =
{ 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 };
static const struct gprs_rlc_cfg rlc_cfg_default = {
@@ -149,10 +148,7 @@ static const struct gprs_rlc_cfg rlc_cfg_default = {
static int gsm_bts_talloc_destructor(struct gsm_bts *bts)
{
- if (bts->site_mgr.mo.fi) {
- osmo_fsm_inst_free(bts->site_mgr.mo.fi);
- bts->site_mgr.mo.fi = NULL;
- }
+ bts->site_mgr->bts[0] = NULL;
if (bts->mo.fi) {
osmo_fsm_inst_free(bts->mo.fi);
bts->mo.fi = NULL;
@@ -164,9 +160,9 @@ static int gsm_bts_talloc_destructor(struct gsm_bts *bts)
* This part is shared among the thin programs in osmo-bsc/src/utils/.
* osmo-bsc requires further initialization that pulls in more dependencies (see
* bsc_bts_alloc_register()). */
-struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, uint8_t bts_num)
+struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, struct gsm_bts_sm *bts_sm, uint8_t bts_num)
{
- struct gsm_bts *bts = talloc_zero(net, struct gsm_bts);
+ struct gsm_bts *bts = talloc_zero(bts_sm, struct gsm_bts);
struct gsm48_multi_rate_conf mr_cfg;
int i;
@@ -182,26 +178,13 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, uint8_t bts_num)
bts->ms_max_power = 15; /* dBm */
- bts->site_mgr.mo.fi = osmo_fsm_inst_alloc(&nm_bts_sm_fsm, bts, &bts->site_mgr,
- LOGL_INFO, NULL);
- osmo_fsm_inst_update_id_f(bts->site_mgr.mo.fi, "bts_sm");
- gsm_mo_init(&bts->site_mgr.mo, bts, NM_OC_SITE_MANAGER, 0xff, 0xff, 0xff);
+ bts->site_mgr = bts_sm;
bts->mo.fi = osmo_fsm_inst_alloc(&nm_bts_fsm, bts, bts,
LOGL_INFO, NULL);
osmo_fsm_inst_update_id_f(bts->mo.fi, "bts%d", bts->nr);
gsm_mo_init(&bts->mo, bts, NM_OC_BTS, bts->nr, 0xff, 0xff);
- for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
- bts->gprs.nsvc[i].bts = bts;
- bts->gprs.nsvc[i].id = i;
- gsm_mo_init(&bts->gprs.nsvc[i].mo, bts, NM_OC_GPRS_NSVC,
- bts->nr, i, 0xff);
- }
- memcpy(&bts->gprs.nse.timer, bts_nse_timer_default,
- sizeof(bts->gprs.nse.timer));
- gsm_mo_init(&bts->gprs.nse.mo, bts, NM_OC_GPRS_NSE,
- bts->nr, 0xff, 0xff);
memcpy(&bts->gprs.cell.timer, bts_cell_timer_default,
sizeof(bts->gprs.cell.timer));
gsm_mo_init(&bts->gprs.cell.mo, bts, NM_OC_GPRS_CELL,
@@ -589,10 +572,6 @@ void gsm_bts_mo_reset(struct gsm_bts *bts)
unsigned int i;
gsm_abis_mo_reset(&bts->mo);
- gsm_abis_mo_reset(&bts->site_mgr.mo);
- for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++)
- gsm_abis_mo_reset(&bts->gprs.nsvc[i].mo);
- gsm_abis_mo_reset(&bts->gprs.nse.mo);
gsm_abis_mo_reset(&bts->gprs.cell.mo);
llist_for_each_entry(trx, &bts->trx_list, list) {
diff --git a/src/osmo-bsc/bts_ipaccess_nanobts.c b/src/osmo-bsc/bts_ipaccess_nanobts.c
index f9dc8b3db..73d6318de 100644
--- a/src/osmo-bsc/bts_ipaccess_nanobts.c
+++ b/src/osmo-bsc/bts_ipaccess_nanobts.c
@@ -133,7 +133,7 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd)
struct gsm_bts_trx *trx;
struct gsm_bts_bb_trx *bb_transc;
struct gsm_bts_trx_ts *ts;
- struct gsm_bts_gprs_nsvc *nsvc;
+ struct gsm_gprs_nsvc *nsvc;
struct msgb *msgb;
@@ -174,7 +174,8 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd)
osmo_fsm_inst_dispatch(trx->mo.fi, NM_EV_STATE_CHG_REP, nsd);
break;
case NM_OC_GPRS_NSE:
- bts = container_of(obj, struct gsm_bts, gprs.nse);
+ bts_sm = container_of(obj, struct gsm_bts_sm, gprs.nse);
+ bts = bts_sm->bts[0];
if (bts->gprs.mode == BTS_GPRS_NONE)
break;
if (new_state->availability == NM_AVSTATE_DEPENDENCY) {
@@ -258,7 +259,7 @@ static int sw_activ_rep(struct msgb *mb)
switch (foh->obj_class) {
case NM_OC_SITE_MANAGER:
- osmo_fsm_inst_dispatch(bts->site_mgr.mo.fi, NM_EV_SW_ACT_REP, NULL);
+ osmo_fsm_inst_dispatch(bts->site_mgr->mo.fi, NM_EV_SW_ACT_REP, NULL);
break;
case NM_OC_BTS:
osmo_fsm_inst_dispatch(bts->mo.fi, NM_EV_SW_ACT_REP, NULL);
@@ -306,7 +307,7 @@ static void nm_rx_opstart_ack(struct msgb *oml_msg)
switch (foh->obj_class) {
case NM_OC_SITE_MANAGER:
- osmo_fsm_inst_dispatch(bts->site_mgr.mo.fi, NM_EV_OPSTART_ACK, NULL);
+ osmo_fsm_inst_dispatch(bts->site_mgr->mo.fi, NM_EV_OPSTART_ACK, NULL);
break;
case NM_OC_BTS:
osmo_fsm_inst_dispatch(bts->mo.fi, NM_EV_OPSTART_ACK, NULL);
@@ -339,7 +340,7 @@ static void nm_rx_opstart_nack(struct msgb *oml_msg)
switch (foh->obj_class) {
case NM_OC_SITE_MANAGER:
- osmo_fsm_inst_dispatch(bts->site_mgr.mo.fi, NM_EV_OPSTART_NACK, NULL);
+ osmo_fsm_inst_dispatch(bts->site_mgr->mo.fi, NM_EV_OPSTART_NACK, NULL);
break;
case NM_OC_BTS:
osmo_fsm_inst_dispatch(bts->mo.fi, NM_EV_OPSTART_ACK, NULL);
@@ -522,7 +523,7 @@ void ipaccess_drop_oml(struct gsm_bts *bts, const char *reason)
}
}
- osmo_fsm_inst_dispatch(bts->site_mgr.mo.fi, NM_EV_OML_DOWN, NULL);
+ osmo_fsm_inst_dispatch(bts->site_mgr->mo.fi, NM_EV_OML_DOWN, NULL);
osmo_fsm_inst_dispatch(bts->mo.fi, NM_EV_OML_DOWN, NULL);
gsm_bts_all_ts_dispatch(bts, TS_EV_OML_DOWN, NULL);
diff --git a/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c b/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c
index 6d64a4bb4..5ad0f47bc 100644
--- a/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c
+++ b/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c
@@ -105,18 +105,19 @@ struct msgb *nanobts_attr_nse_get(struct gsm_bts *bts)
{
struct msgb *msgb;
uint8_t buf[256];
+ struct gsm_bts_sm *bts_sm = bts->site_mgr;
msgb = msgb_alloc(1024, "nanobts_attr_bts");
if (!msgb)
return NULL;
/* NSEI 925 */
- buf[0] = bts->gprs.nse.nsei >> 8;
- buf[1] = bts->gprs.nse.nsei & 0xff;
+ buf[0] = bts_sm->gprs.nse.nsei >> 8;
+ buf[1] = bts_sm->gprs.nse.nsei & 0xff;
msgb_tl16v_put(msgb, NM_ATT_IPACC_NSEI, 2, buf);
/* all timers in seconds */
- OSMO_ASSERT(ARRAY_SIZE(bts->gprs.nse.timer) < sizeof(buf));
- memcpy(buf, bts->gprs.nse.timer, ARRAY_SIZE(bts->gprs.nse.timer));
+ OSMO_ASSERT(ARRAY_SIZE(bts_sm->gprs.nse.timer) < sizeof(buf));
+ memcpy(buf, bts_sm->gprs.nse.timer, ARRAY_SIZE(bts_sm->gprs.nse.timer));
msgb_tl16v_put(msgb, NM_ATT_IPACC_NS_CFG, 7, buf);
/* all timers in seconds */
@@ -202,16 +203,17 @@ struct msgb *nanobts_attr_nscv_get(struct gsm_bts *bts)
{
struct msgb *msgb;
uint8_t buf[256];
+ struct gsm_bts_sm *bts_sm = bts->site_mgr;
msgb = msgb_alloc(1024, "nanobts_attr_bts");
if (!msgb)
return NULL;
/* 925 */
- buf[0] = bts->gprs.nsvc[0].nsvci >> 8;
- buf[1] = bts->gprs.nsvc[0].nsvci & 0xff;
+ buf[0] = bts_sm->gprs.nsvc[0].nsvci >> 8;
+ buf[1] = bts_sm->gprs.nsvc[0].nsvci & 0xff;
msgb_tl16v_put(msgb, NM_ATT_IPACC_NSVCI, 2, buf);
- switch (bts->gprs.nsvc->remote.u.sa.sa_family) {
+ switch (bts_sm->gprs.nsvc->remote.u.sa.sa_family) {
case AF_INET6:
/* all fields are encoded in network byte order */
/* protocol family */
@@ -219,20 +221,20 @@ struct msgb *nanobts_attr_nscv_get(struct gsm_bts *bts)
/* padding */
buf[1] = 0x00;
/* local udp port */
- osmo_store16be(bts->gprs.nsvc[0].local_port, &buf[2]);
+ osmo_store16be(bts_sm->gprs.nsvc[0].local_port, &buf[2]);
/* remote udp port */
- memcpy(&buf[4], &bts->gprs.nsvc[0].remote.u.sin6.sin6_port, sizeof(uint16_t));
+ memcpy(&buf[4], &bts_sm->gprs.nsvc[0].remote.u.sin6.sin6_port, sizeof(uint16_t));
/* remote ip address */
- memcpy(&buf[6], &bts->gprs.nsvc[0].remote.u.sin6.sin6_addr, sizeof(struct in6_addr));
+ memcpy(&buf[6], &bts_sm->gprs.nsvc[0].remote.u.sin6.sin6_addr, sizeof(struct in6_addr));
msgb_tl16v_put(msgb, NM_ATT_OSMO_NS_LINK_CFG, 6 + sizeof(struct in6_addr), buf);
break;
case AF_INET:
/* remote udp port */
- memcpy(&buf[0], &bts->gprs.nsvc[0].remote.u.sin.sin_port, sizeof(uint16_t));
+ memcpy(&buf[0], &bts_sm->gprs.nsvc[0].remote.u.sin.sin_port, sizeof(uint16_t));
/* remote ip address */
- memcpy(&buf[2], &bts->gprs.nsvc[0].remote.u.sin.sin_addr, sizeof(struct in_addr));
+ memcpy(&buf[2], &bts_sm->gprs.nsvc[0].remote.u.sin.sin_addr, sizeof(struct in_addr));
/* local udp port */
- osmo_store16be(bts->gprs.nsvc[0].local_port, &buf[6]);
+ osmo_store16be(bts_sm->gprs.nsvc[0].local_port, &buf[6]);
msgb_tl16v_put(msgb, NM_ATT_IPACC_NS_LINK_CFG, 8, buf);
break;
default:
diff --git a/src/osmo-bsc/bts_nokia_site.c b/src/osmo-bsc/bts_nokia_site.c
index 2b6f91876..3820eaddf 100644
--- a/src/osmo-bsc/bts_nokia_site.c
+++ b/src/osmo-bsc/bts_nokia_site.c
@@ -1452,7 +1452,7 @@ static void nokia_abis_nm_fake_1221_ok(struct gsm_bts *bts)
struct gsm_bts_trx *trx;
mo_ok(&bts->mo);
- mo_ok(&bts->site_mgr.mo);
+ mo_ok(&bts->site_mgr->mo);
llist_for_each_entry(trx, &bts->trx_list, list) {
int i;
diff --git a/src/osmo-bsc/bts_sm.c b/src/osmo-bsc/bts_sm.c
new file mode 100644
index 000000000..a016124d9
--- /dev/null
+++ b/src/osmo-bsc/bts_sm.c
@@ -0,0 +1,85 @@
+/* (C) 2008-2018 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2020 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <osmocom/gsm/abis_nm.h>
+
+#include <osmocom/bsc/gsm_data.h>
+#include <osmocom/bsc/bts.h>
+#include <osmocom/bsc/debug.h>
+#include <osmocom/bsc/nm_common_fsm.h>
+
+static const uint8_t bts_nse_timer_default[] = { 3, 3, 3, 3, 30, 3, 10 };
+
+static int gsm_bts_sm_talloc_destructor(struct gsm_bts_sm *bts_sm)
+{
+ if (bts_sm->mo.fi) {
+ osmo_fsm_inst_free(bts_sm->mo.fi);
+ bts_sm->mo.fi = NULL;
+ }
+ return 0;
+}
+
+struct gsm_bts_sm *gsm_bts_sm_alloc(struct gsm_network *net, uint8_t bts_num)
+{
+ struct gsm_bts_sm *bts_sm = talloc_zero(net, struct gsm_bts_sm);
+ struct gsm_bts *bts;
+ int i;
+ if (!bts_sm)
+ return NULL;
+
+ talloc_set_destructor(bts_sm, gsm_bts_sm_talloc_destructor);
+ bts_sm->mo.fi = osmo_fsm_inst_alloc(&nm_bts_sm_fsm, bts_sm, bts_sm,
+ LOGL_INFO, NULL);
+ osmo_fsm_inst_update_id_f(bts_sm->mo.fi, "bts_sm");
+
+ bts = gsm_bts_alloc(net, bts_sm, bts_num);
+ if (!bts) {
+ talloc_free(bts_sm);
+ return NULL;
+ }
+ bts_sm->bts[0] = bts;
+
+ gsm_mo_init(&bts_sm->mo, bts, NM_OC_SITE_MANAGER, 0xff, 0xff, 0xff);
+
+ for (i = 0; i < ARRAY_SIZE(bts_sm->gprs.nsvc); i++) {
+ bts_sm->gprs.nsvc[i].bts = bts;
+ bts_sm->gprs.nsvc[i].id = i;
+ gsm_mo_init(&bts_sm->gprs.nsvc[i].mo, bts, NM_OC_GPRS_NSVC,
+ bts->nr, i, 0xff);
+ }
+ memcpy(&bts_sm->gprs.nse.timer, bts_nse_timer_default,
+ sizeof(bts_sm->gprs.nse.timer));
+ gsm_mo_init(&bts_sm->gprs.nse.mo, bts, NM_OC_GPRS_NSE,
+ bts->nr, 0xff, 0xff);
+
+ return bts_sm;
+}
+
+void gsm_bts_sm_mo_reset(struct gsm_bts_sm *bts_sm)
+{
+ int i;
+ gsm_abis_mo_reset(&bts_sm->mo);
+
+ gsm_abis_mo_reset(&bts_sm->gprs.nse.mo);
+ for (i = 0; i < ARRAY_SIZE(bts_sm->gprs.nsvc); i++)
+ gsm_abis_mo_reset(&bts_sm->gprs.nsvc[i].mo);
+
+ gsm_bts_mo_reset(bts_sm->bts[0]);
+}
diff --git a/src/osmo-bsc/gsm_data.c b/src/osmo-bsc/gsm_data.c
index 22616f37d..28f7c27b3 100644
--- a/src/osmo-bsc/gsm_data.c
+++ b/src/osmo-bsc/gsm_data.c
@@ -110,14 +110,16 @@ struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net, enum gsm_bts_typ
uint8_t bsic)
{
struct gsm_bts_model *model = bts_model_find(type);
+ struct gsm_bts_sm *bts_sm;
struct gsm_bts *bts;
if (!model && type != GSM_BTS_TYPE_UNKNOWN)
return NULL;
- bts = gsm_bts_alloc(net, net->num_bts);
- if (!bts)
+ bts_sm = gsm_bts_sm_alloc(net, net->num_bts);
+ if (!bts_sm)
return NULL;
+ bts = bts_sm->bts[0];
net->num_bts++;
@@ -378,7 +380,7 @@ gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
mo = &trx->ts[obj_inst->ts_nr].mo;
break;
case NM_OC_SITE_MANAGER:
- mo = &bts->site_mgr.mo;
+ mo = &bts->site_mgr->mo;
break;
case NM_OC_BS11:
switch (obj_inst->bts_nr) {
@@ -410,15 +412,15 @@ gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
mo = &bts->bs11.envabtse[obj_inst->trx_nr].mo;
break;
case NM_OC_GPRS_NSE:
- mo = &bts->gprs.nse.mo;
+ mo = &bts->site_mgr->gprs.nse.mo;
break;
case NM_OC_GPRS_CELL:
mo = &bts->gprs.cell.mo;
break;
case NM_OC_GPRS_NSVC:
- if (obj_inst->trx_nr >= ARRAY_SIZE(bts->gprs.nsvc))
+ if (obj_inst->trx_nr >= ARRAY_SIZE(bts->site_mgr->gprs.nsvc))
return NULL;
- mo = &bts->gprs.nsvc[obj_inst->trx_nr].mo;
+ mo = &bts->site_mgr->gprs.nsvc[obj_inst->trx_nr].mo;
break;
}
return mo;
@@ -474,18 +476,18 @@ gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
obj = &trx->ts[obj_inst->ts_nr];
break;
case NM_OC_SITE_MANAGER:
- obj = &bts->site_mgr;
+ obj = bts->site_mgr;
break;
case NM_OC_GPRS_NSE:
- obj = &bts->gprs.nse;
+ obj = &bts->site_mgr->gprs.nse;
break;
case NM_OC_GPRS_CELL:
obj = &bts->gprs.cell;
break;
case NM_OC_GPRS_NSVC:
- if (obj_inst->trx_nr >= ARRAY_SIZE(bts->gprs.nsvc))
+ if (obj_inst->trx_nr >= ARRAY_SIZE(bts->site_mgr->gprs.nsvc))
return NULL;
- obj = &bts->gprs.nsvc[obj_inst->trx_nr];
+ obj = &bts->site_mgr->gprs.nsvc[obj_inst->trx_nr];
break;
}
return obj;
diff --git a/src/osmo-bsc/nm_bb_transc_fsm.c b/src/osmo-bsc/nm_bb_transc_fsm.c
index c29f53d3c..e7132e85e 100644
--- a/src/osmo-bsc/nm_bb_transc_fsm.c
+++ b/src/osmo-bsc/nm_bb_transc_fsm.c
@@ -113,7 +113,7 @@ static void st_op_disabled_dependency_on_enter(struct osmo_fsm_inst *fi, uint32_
struct gsm_bts_bb_trx *bb_transc = (struct gsm_bts_bb_trx *)fi->priv;
struct gsm_bts_trx *trx = gsm_bts_bb_trx_get_trx(bb_transc);
- if (trx->bts->site_mgr.peer_has_no_avstate_offline) {
+ if (trx->bts->site_mgr->peer_has_no_avstate_offline) {
nm_bb_transc_fsm_state_chg(fi, NM_BB_TRANSC_ST_OP_DISABLED_OFFLINE);
return;
}
@@ -187,7 +187,7 @@ static void st_op_disabled_offline(struct osmo_fsm_inst *fi, uint32_t event, voi
case NM_AVSTATE_DEPENDENCY:
/* There's no point in moving back to Dependency, since it's broken
and it acts actually as if it was in Offline state */
- if (!trx->bts->site_mgr.peer_has_no_avstate_offline) {
+ if (!trx->bts->site_mgr->peer_has_no_avstate_offline) {
nm_bb_transc_fsm_state_chg(fi, NM_BB_TRANSC_ST_OP_DISABLED_DEPENDENCY);
} else {
/* Moreover, in nanoBTS we need to check here for tx
diff --git a/src/osmo-bsc/nm_bts_fsm.c b/src/osmo-bsc/nm_bts_fsm.c
index 5f47fdcc1..6c577bd7c 100644
--- a/src/osmo-bsc/nm_bts_fsm.c
+++ b/src/osmo-bsc/nm_bts_fsm.c
@@ -119,7 +119,7 @@ static void st_op_disabled_dependency_on_enter(struct osmo_fsm_inst *fi, uint32_
/* nanoBTS is broken, doesn't follow TS 12.21. Opstart MUST be sent
during Dependency, so we simply move to OFFLINE state here to avoid
duplicating code */
- if (bts->site_mgr.peer_has_no_avstate_offline) {
+ if (bts->site_mgr->peer_has_no_avstate_offline) {
nm_bts_fsm_state_chg(fi, NM_BTS_ST_OP_DISABLED_OFFLINE);
return;
}
@@ -202,7 +202,7 @@ static void st_op_disabled_offline(struct osmo_fsm_inst *fi, uint32_t event, voi
case NM_AVSTATE_DEPENDENCY:
/* There's no point in moving back to Dependency, since it's broken
and it acts actually as if it was in Offline state */
- if (!bts->site_mgr.peer_has_no_avstate_offline) {
+ if (!bts->site_mgr->peer_has_no_avstate_offline) {
nm_bts_fsm_state_chg(fi, NM_BTS_ST_OP_DISABLED_DEPENDENCY);
} else {
/* Moreover, in nanoBTS we need to check here for tx
diff --git a/src/osmo-bsc/nm_bts_sm_fsm.c b/src/osmo-bsc/nm_bts_sm_fsm.c
index ce9e15b0e..e5b5a3cbe 100644
--- a/src/osmo-bsc/nm_bts_sm_fsm.c
+++ b/src/osmo-bsc/nm_bts_sm_fsm.c
@@ -78,7 +78,7 @@ static void st_op_disabled_notinstalled(struct osmo_fsm_inst *fi, uint32_t event
"have your .cfg with 'type nanobts'. Otherwise, you probably "
"are using an old osmo-bts; automatically adjusting OML "
"behavior to be backward-compatible.\n");
- bts->site_mgr.peer_has_no_avstate_offline = true;
+ site_mgr->peer_has_no_avstate_offline = true;
}
nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_ENABLED);
return;
diff --git a/src/osmo-bsc/nm_channel_fsm.c b/src/osmo-bsc/nm_channel_fsm.c
index 676c471e6..620051a42 100644
--- a/src/osmo-bsc/nm_channel_fsm.c
+++ b/src/osmo-bsc/nm_channel_fsm.c
@@ -125,7 +125,7 @@ static void st_op_disabled_dependency_on_enter(struct osmo_fsm_inst *fi, uint32_
{
struct gsm_bts_trx_ts *ts = (struct gsm_bts_trx_ts *)fi->priv;
- if (ts->trx->bts->site_mgr.peer_has_no_avstate_offline) {
+ if (ts->trx->bts->site_mgr->peer_has_no_avstate_offline) {
nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_OFFLINE);
return;
}
@@ -208,7 +208,7 @@ static void st_op_disabled_offline(struct osmo_fsm_inst *fi, uint32_t event, voi
case NM_AVSTATE_DEPENDENCY:
/* There's no point in moving back to Dependency, since it's broken
and it acts actually as if it was in Offline state */
- if (!ts->trx->bts->site_mgr.peer_has_no_avstate_offline) {
+ if (!ts->trx->bts->site_mgr->peer_has_no_avstate_offline) {
nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_DEPENDENCY);
} else {
/* Moreover, in nanoBTS we need to check here for tx
diff --git a/src/osmo-bsc/osmo_bsc_main.c b/src/osmo-bsc/osmo_bsc_main.c
index cc02c71fa..3be859391 100644
--- a/src/osmo-bsc/osmo_bsc_main.c
+++ b/src/osmo-bsc/osmo_bsc_main.c
@@ -424,7 +424,7 @@ static int inp_sig_cb(unsigned int subsys, unsigned int signal,
osmo_timer_del(&trx->bts->cbch_timer);
}
- gsm_bts_mo_reset(trx->bts);
+ gsm_bts_sm_mo_reset(trx->bts->site_mgr);
abis_nm_clear_queue(trx->bts);
break;
@@ -529,7 +529,7 @@ static int bootstrap_bts(struct gsm_bts *bts)
/* ACC ramping is initialized from vty/config */
/* Initialize the BTS state */
- gsm_bts_mo_reset(bts);
+ gsm_bts_sm_mo_reset(bts->site_mgr);
return 0;
}
diff --git a/src/osmo-bsc/pcu_sock.c b/src/osmo-bsc/pcu_sock.c
index 541fc8493..329bab0f8 100644
--- a/src/osmo-bsc/pcu_sock.c
+++ b/src/osmo-bsc/pcu_sock.c
@@ -46,6 +46,7 @@
#include <osmocom/bsc/abis_rsl.h>
#include <osmocom/bsc/gsm_04_08_rr.h>
#include <osmocom/bsc/bts.h>
+#include <osmocom/bsc/bts_sm.h>
static int pcu_sock_send(struct gsm_bts *bts, struct msgb *msg);
uint32_t trx_get_hlayer1(struct gsm_bts_trx *trx);
@@ -115,13 +116,17 @@ static int pcu_tx_info_ind(struct gsm_bts *bts)
struct gsm_pcu_if *pcu_prim;
struct gsm_pcu_if_info_ind *info_ind;
struct gprs_rlc_cfg *rlcc;
- struct gsm_bts_gprs_nsvc *nsvc;
+ struct gsm_bts_sm *bts_sm;
+ struct gsm_gprs_nsvc *nsvc;
struct gsm_bts_trx *trx;
struct gsm_bts_trx_ts *ts;
int i, tn;
OSMO_ASSERT(bts);
OSMO_ASSERT(bts->network);
+ OSMO_ASSERT(bts->site_mgr);
+
+ bts_sm = bts->site_mgr;
LOGP(DPCU, LOGL_INFO, "Sending info for BTS %d\n",bts->nr);
@@ -147,8 +152,8 @@ static int pcu_tx_info_ind(struct gsm_bts *bts)
info_ind->rac = bts->gprs.rac;
/* NSE */
- info_ind->nsei = bts->gprs.nse.nsei;
- memcpy(info_ind->nse_timer, bts->gprs.nse.timer, 7);
+ info_ind->nsei = bts_sm->gprs.nse.nsei;
+ memcpy(info_ind->nse_timer, bts_sm->gprs.nse.timer, 7);
memcpy(info_ind->cell_timer, bts->gprs.cell.timer, 11);
/* cell attributes */
@@ -202,7 +207,7 @@ static int pcu_tx_info_ind(struct gsm_bts *bts)
/* NSVC */
for (i = 0; i < ARRAY_SIZE(info_ind->nsvci); i++) {
- nsvc = &bts->gprs.nsvc[i];
+ nsvc = &bts->site_mgr->gprs.nsvc[i];
info_ind->nsvci[i] = nsvc->nsvci;
info_ind->local_port[i] = nsvc->local_port;
diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am
index 65fd8fa27..dfc68c5b1 100644
--- a/src/utils/Makefile.am
+++ b/src/utils/Makefile.am
@@ -50,6 +50,7 @@ bs11_config_LDADD = \
$(top_builddir)/src/osmo-bsc/abis_nm.o \
$(top_builddir)/src/osmo-bsc/acc.o \
$(top_builddir)/src/osmo-bsc/bts.o \
+ $(top_builddir)/src/osmo-bsc/bts_sm.o \
$(top_builddir)/src/osmo-bsc/bts_trx.o \
$(top_builddir)/src/osmo-bsc/bts_siemens_bs11.o \
$(top_builddir)/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.o \
@@ -130,6 +131,7 @@ meas_json_LDADD = \
$(top_builddir)/src/osmo-bsc/abis_nm.o \
$(top_builddir)/src/osmo-bsc/acc.o \
$(top_builddir)/src/osmo-bsc/bts.o \
+ $(top_builddir)/src/osmo-bsc/bts_sm.o \
$(top_builddir)/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.o \
$(top_builddir)/src/osmo-bsc/bts_trx.o \
$(top_builddir)/src/osmo-bsc/gsm_data.o \