osmo-bts/src/osmo-bts-trx
Neels Hofmeyr 2ed03cd640 osmo-bts-trx: init OML only once by sending AVSTATE_OK with OPSTATE_ENABLED
When receiving an OPSTART for the BTS object, also set the availability state
to OK.

Before, the availability would remain at NM_AVSTATE_DEPENDENCY, which caused an
unfortunate chain reaction resulting in osmo-bts-trx going through the
initialization sequence twice:

  BTS    BSC
   |<-----|   SITE_MANAGER OPSTART
 n |----->|   BTS state change: OPSTATE_DISABLED, AVSTATE_DEPENDENCY
 o |      |     This signals to nm_statechg_event() in bts_ipaccess_nanobts.c
 r |      |     to (a) Set BTS Attributes and (b) send BTS OPSTART
 m |<-----|   Set BTS Attributes (a)
 a |      |     When osmo-bts-trx receives a Set BTS Attributes, it sends
 l |----->|   CHANNEL state change: OPSTATE_DISABLED  x8
   |      |     This signals the BSC to Set CHANNEL Attributes and OPSTART
 i |<-----|   Set CHANNEL Attributes  x8
 n |<-----|   CHANNEL OPSTART  x8
 i |----->|   CHANNEL state change: OPSTATE_ENABLED, AVSTATE_OK  x8
 t |      |
   |<-----|   BTS OPSTART (b)
   |      |     osmo-bts-trx immediately replies with:
   |----->|   BTS state change: OPSTATE_ENABLED, AVSTATE_DEPENDENCY
   |      |     Unfortunately, availability is left at DEPENDENCY,
   |      |     and the NM_OC_BTS case in nm_statechg_event() only
   |      |     checks for availability, not for the opstate.
   |      |     Hence nm_statechg_event() again feels inclined to
   |      |     to (a) Set BTS Attributes and (b) send BTS OPSTART,
   |      |
 --+------+----- This is where the second round starts
   |      |
 s |<-----|   Set BTS Attributes (a)
 e |      |     When osmo-bts-trx receives a Set BTS Attributes, it sends
 c |----->|   CHANNEL state change: OPSTATE_DISABLED  x8
 o |      |     All channels are disabled again, and then re-launched:
 n |<-----|   Set CHANNEL Attributes  x8
 d |<-----|   CHANNEL OPSTART  x8
   |----->|   CHANNEL state change: OPSTATE_ENABLED, AVSTATE_OK  x8
   |      |
 i |<-----|   BTS OPSTART (b)
 n |      |     osmo-bts-trx again sets the OPSTATE_ENABLED, but since
 i |      |     this time it was already enabled, no further state change
 t |      |     is sent back to the BSC.

This nightmare pivots on two hinges:

1. osmo-bts-trx fails to set BTS availability to AVSTATE_OK.
2. nm_statechg_event() fails to heed the OPSTATE_ENABLED of the BTS state
   change.

Note, the configured channels from the first round were not actually taken
down, only the OML OPSTATE_DISABLED were sent.

In this commit, fix the osmo-bts-trx side: send AVSTATE_OK for the BTS object
upon sending OPSTATE_ENABLED, so that only the part marked "normal init" above
is run.

This change applies the same fix to other OML objects, which should make sense
in the same manner, within the current hackish OML implementation:
* NM_OC_BTS
* NM_OC_SITE_MANAGER
* NM_OC_BASEB_TRANSC
* NM_OC_GPRS_NSE
* NM_OC_GPRS_CELL
* NM_OC_GPRS_NSVC

This means that the NM_OC_CHANNEL case just above is identical, and thus
collapse NM_OC_CHANNEL onto the other cases. Drop the comments from
NM_OC_CHANNEL since they merely rephrase the commands themselves.

See OS#1770 for BTS and NITB logs.

Fixes: OS#1770

Change-Id: I08aa861f6100568c79750f4fbc9a32e1557b9304
2016-07-14 03:40:50 +02:00
..
Makefile.am Use libosmocodec functions for AMR 2016-06-21 17:24:50 +02:00
gsm0503_coding.c TRX: Don't hard-code 23 bytes, use GSM_MACBLOCK_LEN 2016-01-16 17:49:08 +01:00
gsm0503_coding.h trx: Implement BER calculations. 2015-09-22 16:41:31 +02:00
gsm0503_conv.c TRX: Remove extra TCH/HS puncturing value 2015-09-22 16:41:31 +02:00
gsm0503_conv.h TRX: Support for AMR half speech 2015-09-22 16:41:28 +02:00
gsm0503_interleaving.c TRX: Support for TCH/H and GSM half rate transcoding 2015-09-22 16:41:27 +02:00
gsm0503_interleaving.h TRX: Support for TCH/H and GSM half rate transcoding 2015-09-22 16:41:27 +02:00
gsm0503_mapping.c TRX: Code cleanup, prepare for other codecs than GSM full rate 2015-09-22 16:41:27 +02:00
gsm0503_mapping.h TRX: Code cleanup, prepare for other codecs than GSM full rate 2015-09-22 16:41:27 +02:00
gsm0503_parity.c TRX: Support for TCH/H and GSM half rate transcoding 2015-09-22 16:41:27 +02:00
gsm0503_parity.h TRX: Support for AMR full speech 2015-09-22 16:41:27 +02:00
gsm0503_tables.c TRX: Support for AMR half speech 2015-09-22 16:41:28 +02:00
gsm0503_tables.h TRX: Support for AMR half speech 2015-09-22 16:41:28 +02:00
l1_if.c osmo-bts-trx: init OML only once by sending AVSTATE_OK with OPSTATE_ENABLED 2016-07-14 03:40:50 +02:00
l1_if.h Introduce new phy_link and phy_instance abstraction 2016-02-15 14:18:59 +01:00
loops.c TRX: factor out the scheduler from remaining code 2016-02-15 14:17:55 +01:00
loops.h TRX: factor out the scheduler from remaining code 2016-02-15 14:17:55 +01:00
main.c Introduce new phy_link and phy_instance abstraction 2016-02-15 14:18:59 +01:00
scheduler_trx.c log: osmo-bts-trx: change PDTCH block logs to DEBUG level 2016-07-09 19:52:18 +00:00
trx_if.c Clarify logging message 2016-06-22 23:24:43 +00:00
trx_if.h Introduce new phy_link and phy_instance abstraction 2016-02-15 14:18:59 +01:00
trx_vty.c TRX: Add vty command to power on/off transceiver 2016-06-16 13:39:42 +00:00