Change in osmo-bsc[master]: Introduce NM GPRS CELL FSM

2020-12-04 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/21463 )

Change subject: Introduce NM GPRS CELL FSM
..

Introduce NM GPRS CELL FSM

Related: OS#4870
Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
---
M include/osmocom/bsc/nm_common_fsm.h
M src/ipaccess/Makefile.am
M src/osmo-bsc/Makefile.am
M src/osmo-bsc/bts.c
M src/osmo-bsc/bts_ipaccess_nanobts.c
A src/osmo-bsc/nm_gprs_cell_fsm.c
M src/utils/Makefile.am
M tests/abis/Makefile.am
M tests/acc/Makefile.am
M tests/acc/acc_test.ok
M tests/bsc/Makefile.am
M tests/gsm0408/Makefile.am
M tests/handover/Makefile.am
M tests/nanobts_omlattr/Makefile.am
14 files changed, 481 insertions(+), 23 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/include/osmocom/bsc/nm_common_fsm.h 
b/include/osmocom/bsc/nm_common_fsm.h
index b8b821f..a18da3a 100644
--- a/include/osmocom/bsc/nm_common_fsm.h
+++ b/include/osmocom/bsc/nm_common_fsm.h
@@ -91,3 +91,12 @@
NM_GPRS_NSE_ST_OP_ENABLED,
 };
 extern struct osmo_fsm nm_gprs_nse_fsm;
+
+/* GPRS Cell */
+enum nm_gprs_op_cell_states {
+   NM_GPRS_CELL_ST_OP_DISABLED_NOTINSTALLED,
+   NM_GPRS_CELL_ST_OP_DISABLED_DEPENDENCY,
+   NM_GPRS_CELL_ST_OP_DISABLED_OFFLINE,
+   NM_GPRS_CELL_ST_OP_ENABLED,
+};
+extern struct osmo_fsm nm_gprs_cell_fsm;
diff --git a/src/ipaccess/Makefile.am b/src/ipaccess/Makefile.am
index e226206..eadb30e 100644
--- a/src/ipaccess/Makefile.am
+++ b/src/ipaccess/Makefile.am
@@ -60,6 +60,7 @@
$(top_builddir)/src/osmo-bsc/nm_bts_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_bb_transc_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_channel_fsm.o \
+   $(top_builddir)/src/osmo-bsc/nm_gprs_cell_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_gprs_nse_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_rcarrier_fsm.o \
$(OSMO_LIBS) \
@@ -83,6 +84,7 @@
$(top_builddir)/src/osmo-bsc/nm_bts_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_bb_transc_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_channel_fsm.o \
+   $(top_builddir)/src/osmo-bsc/nm_gprs_cell_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_gprs_nse_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_rcarrier_fsm.o \
$(OSMO_LIBS) \
diff --git a/src/osmo-bsc/Makefile.am b/src/osmo-bsc/Makefile.am
index b1b2cc6..79fc164 100644
--- a/src/osmo-bsc/Makefile.am
+++ b/src/osmo-bsc/Makefile.am
@@ -81,6 +81,7 @@
nm_bb_transc_fsm.c \
nm_bts_sm_fsm.c \
nm_bts_fsm.c \
+   nm_gprs_cell_fsm.c \
nm_gprs_nse_fsm.c \
nm_channel_fsm.c \
nm_rcarrier_fsm.c \
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index 2c6b0f1..0c7fde9 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -149,6 +149,12 @@
 static int gsm_bts_talloc_destructor(struct gsm_bts *bts)
 {
bts->site_mgr->bts[0] = NULL;
+
+   if (bts->gprs.cell.mo.fi) {
+   osmo_fsm_inst_free(bts->gprs.cell.mo.fi);
+   bts->gprs.cell.mo.fi = NULL;
+   }
+
if (bts->mo.fi) {
osmo_fsm_inst_free(bts->mo.fi);
bts->mo.fi = NULL;
@@ -185,15 +191,17 @@
osmo_fsm_inst_update_id_f(bts->mo.fi, "bts%d", bts->nr);
gsm_mo_init(>mo, bts, NM_OC_BTS, bts->nr, 0xff, 0xff);

-   memcpy(>gprs.cell.timer, bts_cell_timer_default,
-   sizeof(bts->gprs.cell.timer));
-   gsm_mo_init(>gprs.cell.mo, bts, NM_OC_GPRS_CELL,
-   bts->nr, 0xff, 0xff);
-   memcpy(>gprs.cell.rlc_cfg, _cfg_default,
-   sizeof(bts->gprs.cell.rlc_cfg));
-
/* 3GPP TS 08.18, chapter 5.4.1: 0 is reserved for signalling */
bts->gprs.cell.bvci = 2;
+   memcpy(>gprs.cell.timer, bts_cell_timer_default,
+   sizeof(bts->gprs.cell.timer));
+   memcpy(>gprs.cell.rlc_cfg, _cfg_default,
+   sizeof(bts->gprs.cell.rlc_cfg));
+   bts->gprs.cell.mo.fi = osmo_fsm_inst_alloc(_gprs_cell_fsm, bts,
+  >gprs.cell, LOGL_INFO, 
NULL);
+   osmo_fsm_inst_update_id_f(bts->gprs.cell.mo.fi, "gprs-cell%d", bts->nr);
+   gsm_mo_init(>gprs.cell.mo, bts, NM_OC_GPRS_CELL,
+   bts->nr, 0xff, 0xff);

/* init statistics */
bts->bts_ctrs = rate_ctr_group_alloc(bts, _ctrg_desc, bts->nr);
diff --git a/src/osmo-bsc/bts_ipaccess_nanobts.c 
b/src/osmo-bsc/bts_ipaccess_nanobts.c
index 7d0a2c0..91c76f1 100644
--- a/src/osmo-bsc/bts_ipaccess_nanobts.c
+++ b/src/osmo-bsc/bts_ipaccess_nanobts.c
@@ -136,6 +136,7 @@
struct gsm_bts_trx_ts *ts;
struct gsm_gprs_nsvc *nsvc;
struct gsm_gprs_nse *nse;
+   struct gsm_gprs_cell *cell;

struct msgb *msgb;

@@ -151,6 +152,7 @@
obj_class != NM_OC_RADIO_CARRIER &&
obj_class != NM_OC_CHANNEL &&
obj_class != NM_OC_GPRS_NSE &&
+   obj_class != 

Change in osmo-bsc[master]: Introduce NM GPRS CELL FSM

2020-12-04 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/21463 )

Change subject: Introduce NM GPRS CELL FSM
..


Patch Set 4: Code-Review+2


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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
Gerrit-Change-Number: 21463
Gerrit-PatchSet: 4
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Comment-Date: Fri, 04 Dec 2020 18:32:23 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-bsc[master]: Introduce NM GPRS CELL FSM

2020-12-03 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/21463 )

Change subject: Introduce NM GPRS CELL FSM
..


Patch Set 4: Code-Review+1


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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
Gerrit-Change-Number: 21463
Gerrit-PatchSet: 4
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Comment-Date: Thu, 03 Dec 2020 22:56:04 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-bsc[master]: Introduce NM GPRS CELL FSM

2020-12-03 Thread pespin
Hello Jenkins Builder, laforge, lynxis lazus,

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

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

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

Change subject: Introduce NM GPRS CELL FSM
..

Introduce NM GPRS CELL FSM

Related: OS#4870
Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
---
M include/osmocom/bsc/nm_common_fsm.h
M src/ipaccess/Makefile.am
M src/osmo-bsc/Makefile.am
M src/osmo-bsc/bts.c
M src/osmo-bsc/bts_ipaccess_nanobts.c
A src/osmo-bsc/nm_gprs_cell_fsm.c
M src/utils/Makefile.am
M tests/abis/Makefile.am
M tests/acc/Makefile.am
M tests/acc/acc_test.ok
M tests/bsc/Makefile.am
M tests/gsm0408/Makefile.am
M tests/handover/Makefile.am
M tests/nanobts_omlattr/Makefile.am
14 files changed, 481 insertions(+), 23 deletions(-)


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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
Gerrit-Change-Number: 21463
Gerrit-PatchSet: 4
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-MessageType: newpatchset


Change in osmo-bsc[master]: Introduce NM GPRS CELL FSM

2020-12-03 Thread pespin
Hello Jenkins Builder, laforge, lynxis lazus,

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

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

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

Change subject: Introduce NM GPRS CELL FSM
..

Introduce NM GPRS CELL FSM

Related: OS#4870
Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
---
M include/osmocom/bsc/nm_common_fsm.h
M src/ipaccess/Makefile.am
M src/osmo-bsc/Makefile.am
M src/osmo-bsc/bts.c
M src/osmo-bsc/bts_ipaccess_nanobts.c
A src/osmo-bsc/nm_gprs_cell_fsm.c
M src/utils/Makefile.am
M tests/abis/Makefile.am
M tests/acc/Makefile.am
M tests/acc/acc_test.ok
M tests/bsc/Makefile.am
M tests/gsm0408/Makefile.am
M tests/handover/Makefile.am
M tests/nanobts_omlattr/Makefile.am
14 files changed, 480 insertions(+), 23 deletions(-)


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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
Gerrit-Change-Number: 21463
Gerrit-PatchSet: 3
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-MessageType: newpatchset


Change in osmo-bsc[master]: Introduce NM GPRS CELL FSM

2020-12-03 Thread pespin
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/21463 )

Change subject: Introduce NM GPRS CELL FSM
..


Patch Set 2:

(1 comment)

https://gerrit.osmocom.org/c/osmo-bsc/+/21463/2/src/osmo-bsc/nm_gprs_cell_fsm.c
File src/osmo-bsc/nm_gprs_cell_fsm.c:

https://gerrit.osmocom.org/c/osmo-bsc/+/21463/2/src/osmo-bsc/nm_gprs_cell_fsm.c@99
PS2, Line 99:   OSMO_ASSERT(msgb); /* if (!msgb); break; */
> why not if(!msgb)? Should we really segfault on low memory?
That comment should go away, it's a leftover I left now I'm doing tests if I 
find something failing.

TBH, it's not important, that's not going to happen theoretically, in linux 
malloc won't ever fail and return NULL, rather the process will be stalled 
until the kernel allocates memory for it or it is killed by OOM killer, so it 
really doesn't matter. ASSERT has less lines than if + break, that's the only 
reason. Adding the assert there rpovides a quick security + easy way to see 
where the issue was, in the really improbable scenario where NULL is returned, 
which is really not expected.



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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
Gerrit-Change-Number: 21463
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Comment-Date: Thu, 03 Dec 2020 15:37:32 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: lynxis lazus 
Gerrit-MessageType: comment


Change in osmo-bsc[master]: Introduce NM GPRS CELL FSM

2020-12-02 Thread lynxis lazus
lynxis lazus has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/21463 )

Change subject: Introduce NM GPRS CELL FSM
..


Patch Set 2: Code-Review+1


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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
Gerrit-Change-Number: 21463
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Comment-Date: Thu, 03 Dec 2020 02:54:38 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-bsc[master]: Introduce NM GPRS CELL FSM

2020-12-02 Thread lynxis lazus
lynxis lazus has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/21463 )

Change subject: Introduce NM GPRS CELL FSM
..


Patch Set 2:

(1 comment)

https://gerrit.osmocom.org/c/osmo-bsc/+/21463/2/src/osmo-bsc/nm_gprs_cell_fsm.c
File src/osmo-bsc/nm_gprs_cell_fsm.c:

https://gerrit.osmocom.org/c/osmo-bsc/+/21463/2/src/osmo-bsc/nm_gprs_cell_fsm.c@99
PS2, Line 99:   OSMO_ASSERT(msgb); /* if (!msgb); break; */
why not if(!msgb)? Should we really segfault on low memory?



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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
Gerrit-Change-Number: 21463
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Comment-Date: Thu, 03 Dec 2020 02:54:15 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in osmo-bsc[master]: Introduce NM GPRS CELL FSM

2020-12-02 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/21463 )

Change subject: Introduce NM GPRS CELL FSM
..


Patch Set 2: Code-Review+1


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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
Gerrit-Change-Number: 21463
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Comment-Date: Wed, 02 Dec 2020 20:54:09 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-bsc[master]: Introduce NM GPRS CELL FSM

2020-12-02 Thread pespin
Hello Jenkins Builder, lynxis lazus,

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

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

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

Change subject: Introduce NM GPRS CELL FSM
..

Introduce NM GPRS CELL FSM

Related: OS#4870
Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
---
M include/osmocom/bsc/nm_common_fsm.h
M src/ipaccess/Makefile.am
M src/osmo-bsc/Makefile.am
M src/osmo-bsc/bts.c
M src/osmo-bsc/bts_ipaccess_nanobts.c
A src/osmo-bsc/nm_gprs_cell_fsm.c
M src/utils/Makefile.am
M tests/abis/Makefile.am
M tests/acc/Makefile.am
M tests/acc/acc_test.ok
M tests/bsc/Makefile.am
M tests/gsm0408/Makefile.am
M tests/handover/Makefile.am
M tests/nanobts_omlattr/Makefile.am
14 files changed, 469 insertions(+), 23 deletions(-)


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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
Gerrit-Change-Number: 21463
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: lynxis lazus 
Gerrit-MessageType: newpatchset


Change in osmo-bsc[master]: Introduce NM GPRS CELL FSM

2020-12-02 Thread pespin
pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/21463 )


Change subject: Introduce NM GPRS CELL FSM
..

Introduce NM GPRS CELL FSM

Related: OS#4870
Change-Id: I074f4496aa153b5f84e6ce85f413754efe64d831
---
M include/osmocom/bsc/nm_common_fsm.h
M src/ipaccess/Makefile.am
M src/osmo-bsc/Makefile.am
M src/osmo-bsc/bts.c
M src/osmo-bsc/bts_ipaccess_nanobts.c
A src/osmo-bsc/nm_gprs_cell_fsm.c
M src/utils/Makefile.am
M tests/abis/Makefile.am
M tests/acc/Makefile.am
M tests/acc/acc_test.ok
M tests/bsc/Makefile.am
M tests/gsm0408/Makefile.am
M tests/handover/Makefile.am
M tests/nanobts_omlattr/Makefile.am
14 files changed, 469 insertions(+), 23 deletions(-)



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

diff --git a/include/osmocom/bsc/nm_common_fsm.h 
b/include/osmocom/bsc/nm_common_fsm.h
index b8b821f..a18da3a 100644
--- a/include/osmocom/bsc/nm_common_fsm.h
+++ b/include/osmocom/bsc/nm_common_fsm.h
@@ -91,3 +91,12 @@
NM_GPRS_NSE_ST_OP_ENABLED,
 };
 extern struct osmo_fsm nm_gprs_nse_fsm;
+
+/* GPRS Cell */
+enum nm_gprs_op_cell_states {
+   NM_GPRS_CELL_ST_OP_DISABLED_NOTINSTALLED,
+   NM_GPRS_CELL_ST_OP_DISABLED_DEPENDENCY,
+   NM_GPRS_CELL_ST_OP_DISABLED_OFFLINE,
+   NM_GPRS_CELL_ST_OP_ENABLED,
+};
+extern struct osmo_fsm nm_gprs_cell_fsm;
diff --git a/src/ipaccess/Makefile.am b/src/ipaccess/Makefile.am
index e226206..eadb30e 100644
--- a/src/ipaccess/Makefile.am
+++ b/src/ipaccess/Makefile.am
@@ -60,6 +60,7 @@
$(top_builddir)/src/osmo-bsc/nm_bts_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_bb_transc_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_channel_fsm.o \
+   $(top_builddir)/src/osmo-bsc/nm_gprs_cell_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_gprs_nse_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_rcarrier_fsm.o \
$(OSMO_LIBS) \
@@ -83,6 +84,7 @@
$(top_builddir)/src/osmo-bsc/nm_bts_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_bb_transc_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_channel_fsm.o \
+   $(top_builddir)/src/osmo-bsc/nm_gprs_cell_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_gprs_nse_fsm.o \
$(top_builddir)/src/osmo-bsc/nm_rcarrier_fsm.o \
$(OSMO_LIBS) \
diff --git a/src/osmo-bsc/Makefile.am b/src/osmo-bsc/Makefile.am
index b1b2cc6..79fc164 100644
--- a/src/osmo-bsc/Makefile.am
+++ b/src/osmo-bsc/Makefile.am
@@ -81,6 +81,7 @@
nm_bb_transc_fsm.c \
nm_bts_sm_fsm.c \
nm_bts_fsm.c \
+   nm_gprs_cell_fsm.c \
nm_gprs_nse_fsm.c \
nm_channel_fsm.c \
nm_rcarrier_fsm.c \
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index 2c6b0f1..0c7fde9 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -149,6 +149,12 @@
 static int gsm_bts_talloc_destructor(struct gsm_bts *bts)
 {
bts->site_mgr->bts[0] = NULL;
+
+   if (bts->gprs.cell.mo.fi) {
+   osmo_fsm_inst_free(bts->gprs.cell.mo.fi);
+   bts->gprs.cell.mo.fi = NULL;
+   }
+
if (bts->mo.fi) {
osmo_fsm_inst_free(bts->mo.fi);
bts->mo.fi = NULL;
@@ -185,15 +191,17 @@
osmo_fsm_inst_update_id_f(bts->mo.fi, "bts%d", bts->nr);
gsm_mo_init(>mo, bts, NM_OC_BTS, bts->nr, 0xff, 0xff);

-   memcpy(>gprs.cell.timer, bts_cell_timer_default,
-   sizeof(bts->gprs.cell.timer));
-   gsm_mo_init(>gprs.cell.mo, bts, NM_OC_GPRS_CELL,
-   bts->nr, 0xff, 0xff);
-   memcpy(>gprs.cell.rlc_cfg, _cfg_default,
-   sizeof(bts->gprs.cell.rlc_cfg));
-
/* 3GPP TS 08.18, chapter 5.4.1: 0 is reserved for signalling */
bts->gprs.cell.bvci = 2;
+   memcpy(>gprs.cell.timer, bts_cell_timer_default,
+   sizeof(bts->gprs.cell.timer));
+   memcpy(>gprs.cell.rlc_cfg, _cfg_default,
+   sizeof(bts->gprs.cell.rlc_cfg));
+   bts->gprs.cell.mo.fi = osmo_fsm_inst_alloc(_gprs_cell_fsm, bts,
+  >gprs.cell, LOGL_INFO, 
NULL);
+   osmo_fsm_inst_update_id_f(bts->gprs.cell.mo.fi, "gprs-cell%d", bts->nr);
+   gsm_mo_init(>gprs.cell.mo, bts, NM_OC_GPRS_CELL,
+   bts->nr, 0xff, 0xff);

/* init statistics */
bts->bts_ctrs = rate_ctr_group_alloc(bts, _ctrg_desc, bts->nr);
diff --git a/src/osmo-bsc/bts_ipaccess_nanobts.c 
b/src/osmo-bsc/bts_ipaccess_nanobts.c
index 8023323..88e8067 100644
--- a/src/osmo-bsc/bts_ipaccess_nanobts.c
+++ b/src/osmo-bsc/bts_ipaccess_nanobts.c
@@ -136,6 +136,7 @@
struct gsm_bts_trx_ts *ts;
struct gsm_gprs_nsvc *nsvc;
struct gsm_gprs_nse *nse;
+   struct gsm_gprs_cell *cell;

struct msgb *msgb;

@@ -180,22 +181,8 @@
osmo_fsm_inst_dispatch(nse->mo.fi, NM_EV_STATE_CHG_REP, nsd);
break;
case NM_OC_GPRS_CELL:
-   bts =