dexter has uploaded this change for review.

View Change

pcu_sock: activate/deactivate PDCH on pcu reconnect

When the PCU is disconnected while the BSC keeps running the PDCH should
be closed. Also the PDCH should be repopened when the PCU is
reconnected.

Change-Id: I9ea0c53a5e68a51c781ef43bae71f947cdb95678
Related: OS#5198
---
M doc/timeslot.msc
M include/osmocom/bsc/timeslot_fsm.h
M src/osmo-bsc/pcu_sock.c
M src/osmo-bsc/timeslot_fsm.c
4 files changed, 102 insertions(+), 18 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/97/31497/1
diff --git a/doc/timeslot.msc b/doc/timeslot.msc
index 02e7bb3..cf4988d 100644
--- a/doc/timeslot.msc
+++ b/doc/timeslot.msc
@@ -1,5 +1,5 @@
msc {
- bts [label="MS/BTS"], bsc[label="BSC"], bsc_ts[label="BSC timeslot FSM"], bsc_lchan[label="BSC lchan FSM"];
+ bts [label="MS/BTS"], bsc[label="BSC"], bsc_ts[label="BSC timeslot FSM"], bsc_lchan[label="BSC lchan FSM"], pcu_sock[label="PCU socket"];

bsc_ts abox bsc_ts [label="NOT_INITIALIZED"];

@@ -88,6 +88,20 @@
bsc_ts rbox bsc_ts [label="Continue at 'IN_USE' above"];
...;
...;
+ bts rbox bsc_lchan [label="on PCU disconnect (Ericsson RBS)"];
+ bsc_ts abox bsc_ts [label="PDCH"];
+ bsc_ts <- pcu_sock [label="TS_EV_PDCH_DEACT"];
+ bsc_ts box bsc_ts [label="release PDCH"];
+ bsc_ts abox bsc_ts [label="UNUSED"];
+ ...;
+ ...;
+ bts rbox bsc_lchan [label="on PCU reconnect (Ericsson RBS)"];
+ bsc_ts abox bsc_ts [label="PDCH"];
+ bsc_ts <- pcu_sock [label="TS_EV_PDCH_ACT"];
+ bsc_ts box bsc_ts [label="activate PDCH"];
+ bsc_ts abox bsc_ts [label="PDCH"];
+ ...;
+ ...;

bts rbox bsc_lchan [label="on erratic event"];
bsc_ts -> bsc_lchan [label="LCHAN_EV_TS_ERROR"];
diff --git a/include/osmocom/bsc/timeslot_fsm.h b/include/osmocom/bsc/timeslot_fsm.h
index 526f3cf..bcaec1d 100644
--- a/include/osmocom/bsc/timeslot_fsm.h
+++ b/include/osmocom/bsc/timeslot_fsm.h
@@ -40,6 +40,8 @@
TS_EV_PDCH_ACT_NACK,
TS_EV_PDCH_DEACT_ACK,
TS_EV_PDCH_DEACT_NACK,
+ TS_EV_PDCH_DEACT,
+ TS_EV_PDCH_ACT,
};

void ts_fsm_alloc(struct gsm_bts_trx_ts *ts);
diff --git a/src/osmo-bsc/pcu_sock.c b/src/osmo-bsc/pcu_sock.c
index add968a..d1f2c48 100644
--- a/src/osmo-bsc/pcu_sock.c
+++ b/src/osmo-bsc/pcu_sock.c
@@ -44,6 +44,7 @@
#include <osmocom/bsc/gsm_04_08_rr.h>
#include <osmocom/bsc/bts.h>
#include <osmocom/bsc/bts_sm.h>
+#include <osmocom/bsc/timeslot_fsm.h>

static int pcu_sock_send(struct gsm_bts *bts, struct msgb *msg);

@@ -790,15 +791,19 @@
#endif

/* release PDCH */
- for (i = 0; i < 8; i++) {
+ for (i = 0; i < PCU_IF_NUM_TRX; i++) {
trx = gsm_bts_trx_num(bts, i);
if (!trx)
break;
for (j = 0; j < 8; j++) {
ts = &trx->ts[j];
if (ts->mo.nm_state.operational == NM_OPSTATE_ENABLED
- && ts->pchan_is == GSM_PCHAN_PDCH) {
- printf("l1sap_chan_rel(trx,gsm_lchan2chan_nr(ts->lchan));\n");
+ && ts->pchan_on_init == GSM_PCHAN_OSMO_DYN
+ && ts->pchan_is == GSM_PCHAN_PDCH && ts->fi->state == TS_ST_PDCH) {
+ /* NOTE: We send the deactivation event only when the timeslot is active as PDCH. The
+ * timeslot FSM will check internally if the PCU is available and make sure the PDCH
+ * is not activated again. */
+ osmo_fsm_inst_dispatch(ts->fi, TS_EV_PDCH_DEACT, NULL);
}
}
}
@@ -925,9 +930,16 @@
struct pcu_sock_state *state = (struct pcu_sock_state *)bfd->data;
struct osmo_fd *conn_bfd = &state->conn_bfd;
struct sockaddr_un un_addr;
+ struct gsm_bts *bts;
+ struct gsm_bts_trx *trx;
+ struct gsm_bts_trx_ts *ts;
+ int i, j;
socklen_t len;
int rc;

+ /* FIXME: allow multiple BTS */
+ bts = llist_entry(state->net->bts_list.next, struct gsm_bts, list);
+
len = sizeof(un_addr);
rc = accept(bfd->fd, (struct sockaddr *) &un_addr, &len);
if (rc < 0) {
@@ -956,6 +968,22 @@

LOGP(DPCU, LOGL_NOTICE, "PCU socket connected to external PCU\n");

+ /* activate PDCH */
+ for (i = 0; i < PCU_IF_NUM_TRX; i++) {
+ trx = gsm_bts_trx_num(bts, i);
+ if (!trx)
+ break;
+ for (j = 0; j < 8; j++) {
+ ts = &trx->ts[j];
+ if (ts->mo.nm_state.operational == NM_OPSTATE_ENABLED
+ && ts->pchan_on_init == GSM_PCHAN_OSMO_DYN && ts->fi->state == TS_ST_UNUSED) {
+ /* NOTE: We send the activation event only when the timeslot is UNUSED. In all other
+ * cases the timeslot FSM will automatically handle the activation. */
+ osmo_fsm_inst_dispatch(ts->fi, TS_EV_PDCH_ACT, NULL);
+ }
+ }
+ }
+
return 0;
}

diff --git a/src/osmo-bsc/timeslot_fsm.c b/src/osmo-bsc/timeslot_fsm.c
index c7f6130..1ba176f 100644
--- a/src/osmo-bsc/timeslot_fsm.c
+++ b/src/osmo-bsc/timeslot_fsm.c
@@ -323,11 +323,37 @@
chan_counts_ts_clear(ts);
}

-static void ts_fsm_unused_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+static void ts_fsm_unused_pdch_act(struct osmo_fsm_inst *fi)
{
struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
struct gsm_bts *bts = ts->trx->bts;

+ if (bts->gprs.mode == BTS_GPRS_NONE) {
+ LOG_TS(ts, LOGL_DEBUG, "GPRS mode is 'none': not activating PDCH.\n");
+ return;
+ }
+
+ if (!ts->pdch_act_allowed) {
+ LOG_TS(ts, LOGL_DEBUG, "PDCH is disabled for this timeslot,"
+ " either due to a PDCH ACT NACK, or from manual VTY command:"
+ " not activating PDCH. (last error: %s)\n",
+ ts->last_errmsg ? : "-");
+ return;
+ }
+
+ if(is_ericsson_bts(bts) && bts->pcu_state->conn_bfd.fd < 0) {
+ LOG_TS(ts, LOGL_DEBUG, "PCU not connected: not activating PDCH.\n");
+ return;
+ }
+
+ osmo_fsm_inst_state_chg(fi, TS_ST_WAIT_PDCH_ACT, CHAN_ACT_DEACT_TIMEOUT,
+ T_CHAN_ACT_DEACT);
+}
+
+static void ts_fsm_unused_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+ struct gsm_bts_trx_ts *ts = ts_fi_ts(fi);
+
chan_counts_ts_update(ts);

/* We are entering the unused state. There must by definition not be any lchans waiting to be
@@ -342,19 +368,7 @@
switch (ts->pchan_on_init) {
case GSM_PCHAN_OSMO_DYN:
case GSM_PCHAN_TCH_F_PDCH:
- if (bts->gprs.mode == BTS_GPRS_NONE) {
- LOG_TS(ts, LOGL_DEBUG, "GPRS mode is 'none': not activating PDCH.\n");
- return;
- }
- if (!ts->pdch_act_allowed) {
- LOG_TS(ts, LOGL_DEBUG, "PDCH is disabled for this timeslot,"
- " either due to a PDCH ACT NACK, or from manual VTY command:"
- " not activating PDCH. (last error: %s)\n",
- ts->last_errmsg ? : "-");
- return;
- }
- osmo_fsm_inst_state_chg(fi, TS_ST_WAIT_PDCH_ACT, CHAN_ACT_DEACT_TIMEOUT,
- T_CHAN_ACT_DEACT);
+ ts_fsm_unused_pdch_act(fi);
break;

case GSM_PCHAN_CCCH_SDCCH4_CBCH:
@@ -399,6 +413,10 @@
/* ignored. */
return;

+ case TS_EV_PDCH_ACT:
+ ts_fsm_unused_pdch_act(fi);
+ return;
+
default:
OSMO_ASSERT(false);
}
@@ -522,6 +540,10 @@
}
}

+ case TS_EV_PDCH_DEACT:
+ ts_fsm_pdch_deact(fi);
+ return;
+
case TS_EV_LCHAN_UNUSED:
/* ignored */
return;
@@ -880,6 +902,7 @@
.in_event_mask = 0
| S(TS_EV_LCHAN_REQUESTED)
| S(TS_EV_LCHAN_UNUSED)
+ | S(TS_EV_PDCH_ACT)
,
.out_state_mask = 0
| S(TS_ST_WAIT_PDCH_ACT)
@@ -912,6 +935,7 @@
.in_event_mask = 0
| S(TS_EV_LCHAN_REQUESTED)
| S(TS_EV_LCHAN_UNUSED)
+ | S(TS_EV_PDCH_DEACT)
,
.out_state_mask = 0
| S(TS_ST_WAIT_PDCH_DEACT)
@@ -983,6 +1007,8 @@
OSMO_VALUE_STRING(TS_EV_PDCH_ACT_NACK),
OSMO_VALUE_STRING(TS_EV_PDCH_DEACT_ACK),
OSMO_VALUE_STRING(TS_EV_PDCH_DEACT_NACK),
+ OSMO_VALUE_STRING(TS_EV_PDCH_DEACT),
+ OSMO_VALUE_STRING(TS_EV_PDCH_ACT),
{}
};


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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I9ea0c53a5e68a51c781ef43bae71f947cdb95678
Gerrit-Change-Number: 31497
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier@sysmocom.de>
Gerrit-MessageType: newchange