<p>pespin <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-bts/+/19123">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  Hoernchen: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Move gsm_bts code gsm-data.* => bts.*<br><br>bts.h refers to struct gsm_bts object, but we still had a bunch of stuff<br>in bulky gsm_data.* from old days. Let's move stuff where it belongs to<br>start clean up of gsm_data.<br><br>Change-Id: I0a4219e3f64f625ee8b364bf408b8d2bcc8085c5<br>---<br>M include/osmo-bts/bts.h<br>M include/osmo-bts/gsm_data.h<br>M src/common/bts.c<br>M src/common/bts_shutdown_fsm.c<br>M src/common/gsm_data.c<br>M src/common/load_indication.c<br>M src/common/msg_utils.c<br>M src/common/scheduler.c<br>M src/common/sysinfo.c<br>M src/osmo-bts-octphy/l1_if.c<br>M src/osmo-bts-sysmo/sysmobts_vty.c<br>M src/osmo-bts-trx/trx_vty.c<br>12 files changed, 479 insertions(+), 487 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h</span><br><span>index 63412f9..cb8787f 100644</span><br><span>--- a/include/osmo-bts/bts.h</span><br><span>+++ b/include/osmo-bts/bts.h</span><br><span>@@ -24,8 +24,299 @@</span><br><span>  BTS_CTR_AGCH_DELETED,</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Used by OML layer for BTS Attribute reporting */</span><br><span style="color: hsl(120, 100%, 40%);">+enum bts_attribute {</span><br><span style="color: hsl(120, 100%, 40%);">+    BTS_TYPE_VARIANT,</span><br><span style="color: hsl(120, 100%, 40%);">+     BTS_SUB_MODEL,</span><br><span style="color: hsl(120, 100%, 40%);">+        TRX_PHY_VERSION,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+const char *btsatttr2str(enum bts_attribute v);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+enum gsm_bts_type_variant {</span><br><span style="color: hsl(120, 100%, 40%);">+  BTS_UNKNOWN,</span><br><span style="color: hsl(120, 100%, 40%);">+  BTS_OSMO_LITECELL15,</span><br><span style="color: hsl(120, 100%, 40%);">+        BTS_OSMO_OC2G,</span><br><span style="color: hsl(120, 100%, 40%);">+  BTS_OSMO_OCTPHY,</span><br><span style="color: hsl(120, 100%, 40%);">+      BTS_OSMO_SYSMO,</span><br><span style="color: hsl(120, 100%, 40%);">+       BTS_OSMO_TRX,</span><br><span style="color: hsl(120, 100%, 40%);">+ BTS_OSMO_VIRTUAL,</span><br><span style="color: hsl(120, 100%, 40%);">+     BTS_OSMO_OMLDUMMY,</span><br><span style="color: hsl(120, 100%, 40%);">+    _NUM_BTS_VARIANT</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+const char *btsvariant2str(enum gsm_bts_type_variant v);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* TODO: add a brief description of this flag */</span><br><span style="color: hsl(120, 100%, 40%);">+#define BTS_INTERNAL_FLAG_MS_PWR_CTRL_DSP           (1 << 0)</span><br><span style="color: hsl(120, 100%, 40%);">+/* When this flag is set then the measurement data is included in</span><br><span style="color: hsl(120, 100%, 40%);">+ * (PRIM_PH_DATA) and struct ph_tch_param (PRIM_TCH). Otherwise the</span><br><span style="color: hsl(120, 100%, 40%);">+ * measurement data is passed using a separate MPH INFO MEAS IND.</span><br><span style="color: hsl(120, 100%, 40%);">+ * (See also ticket: OS#2977) */</span><br><span style="color: hsl(120, 100%, 40%);">+#define BTS_INTERNAL_FLAG_MEAS_PAYLOAD_COMB                (1 << 1)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* BTS implementation flags (internal use, not exposed via OML) */</span><br><span style="color: hsl(120, 100%, 40%);">+#define bts_internal_flag_get(bts, flag) \</span><br><span style="color: hsl(120, 100%, 40%);">+      ((bts->flags & (typeof(bts->flags)) flag) != 0)</span><br><span style="color: hsl(120, 100%, 40%);">+#define bts_internal_flag_set(bts, flag) \</span><br><span style="color: hsl(120, 100%, 40%);">+ bts->flags |= (typeof(bts->flags)) flag</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm_bts_gprs_nsvc {</span><br><span style="color: hsl(120, 100%, 40%);">+   struct gsm_bts *bts;</span><br><span style="color: hsl(120, 100%, 40%);">+  /* data read via VTY config file, to configure the BTS</span><br><span style="color: hsl(120, 100%, 40%);">+         * via OML from BSC */</span><br><span style="color: hsl(120, 100%, 40%);">+        int id;</span><br><span style="color: hsl(120, 100%, 40%);">+       uint16_t nsvci;</span><br><span style="color: hsl(120, 100%, 40%);">+       uint16_t local_port;    /* on the BTS */</span><br><span style="color: hsl(120, 100%, 40%);">+      uint16_t remote_port;   /* on the SGSN */</span><br><span style="color: hsl(120, 100%, 40%);">+     uint32_t remote_ip;     /* on the SGSN */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   struct gsm_abis_mo mo;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct gprs_rlc_cfg {</span><br><span style="color: hsl(120, 100%, 40%);">+   uint16_t parameter[_NUM_RLC_PAR];</span><br><span style="color: hsl(120, 100%, 40%);">+     struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              uint16_t repeat_time; /* ms */</span><br><span style="color: hsl(120, 100%, 40%);">+                uint8_t repeat_count;</span><br><span style="color: hsl(120, 100%, 40%);">+ } paging;</span><br><span style="color: hsl(120, 100%, 40%);">+     uint32_t cs_mask; /* bitmask of gprs_cs */</span><br><span style="color: hsl(120, 100%, 40%);">+    uint8_t initial_cs;</span><br><span style="color: hsl(120, 100%, 40%);">+   uint8_t initial_mcs;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct bts_smscb_state {</span><br><span style="color: hsl(120, 100%, 40%);">+  struct llist_head queue; /* list of struct smscb_msg */</span><br><span style="color: hsl(120, 100%, 40%);">+       int queue_len;</span><br><span style="color: hsl(120, 100%, 40%);">+        struct rate_ctr_group *ctrs;</span><br><span style="color: hsl(120, 100%, 40%);">+  struct smscb_msg *cur_msg; /* current SMS-CB */</span><br><span style="color: hsl(120, 100%, 40%);">+       struct smscb_msg *default_msg; /* default broadcast message; NULL if none */</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* One BTS */</span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm_bts {</span><br><span style="color: hsl(120, 100%, 40%);">+   /* list header in net->bts_list */</span><br><span style="color: hsl(120, 100%, 40%);">+ struct llist_head list;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* number of the BTS in network */</span><br><span style="color: hsl(120, 100%, 40%);">+    uint8_t nr;</span><br><span style="color: hsl(120, 100%, 40%);">+   /* human readable name / description */</span><br><span style="color: hsl(120, 100%, 40%);">+       char *description;</span><br><span style="color: hsl(120, 100%, 40%);">+    /* Cell Identity */</span><br><span style="color: hsl(120, 100%, 40%);">+   uint16_t cell_identity;</span><br><span style="color: hsl(120, 100%, 40%);">+       /* location area code of this BTS */</span><br><span style="color: hsl(120, 100%, 40%);">+  uint16_t location_area_code;</span><br><span style="color: hsl(120, 100%, 40%);">+  /* Base Station Identification Code (BSIC), lower 3 bits is BCC,</span><br><span style="color: hsl(120, 100%, 40%);">+       * which is used as TSC for the CCCH */</span><br><span style="color: hsl(120, 100%, 40%);">+       uint8_t bsic;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* type of BTS */</span><br><span style="color: hsl(120, 100%, 40%);">+     enum gsm_bts_type_variant variant;</span><br><span style="color: hsl(120, 100%, 40%);">+    enum gsm_band band;</span><br><span style="color: hsl(120, 100%, 40%);">+   char version[MAX_VERSION_LENGTH];</span><br><span style="color: hsl(120, 100%, 40%);">+     char sub_model[MAX_VERSION_LENGTH];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* public features of a given BTS (set/reported via OML) */</span><br><span style="color: hsl(120, 100%, 40%);">+   struct bitvec *features;</span><br><span style="color: hsl(120, 100%, 40%);">+      /* implementation flags of a given BTS (not exposed via OML) */</span><br><span style="color: hsl(120, 100%, 40%);">+       uint16_t flags;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Connected PCU version (if any) */</span><br><span style="color: hsl(120, 100%, 40%);">+  char pcu_version[MAX_VERSION_LENGTH];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       /* maximum Tx power that the MS is permitted to use in this cell */</span><br><span style="color: hsl(120, 100%, 40%);">+   int ms_max_power;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* how do we talk OML with this TRX? */</span><br><span style="color: hsl(120, 100%, 40%);">+       struct e1inp_sign_link *oml_link;</span><br><span style="color: hsl(120, 100%, 40%);">+     struct timespec oml_conn_established_timestamp;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Abis network management O&M handle */</span><br><span style="color: hsl(120, 100%, 40%);">+  struct gsm_abis_mo mo;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      /* number of this BTS on given E1 link */</span><br><span style="color: hsl(120, 100%, 40%);">+     uint8_t bts_nr;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* DTX features of this BTS */</span><br><span style="color: hsl(120, 100%, 40%);">+        bool dtxd;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /* CCCH is on C0 */</span><br><span style="color: hsl(120, 100%, 40%);">+   struct gsm_bts_trx *c0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              struct gsm_abis_mo mo;</span><br><span style="color: hsl(120, 100%, 40%);">+        } site_mgr;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* bitmask of all SI that are present/valid in si_buf */</span><br><span style="color: hsl(120, 100%, 40%);">+      uint32_t si_valid;</span><br><span style="color: hsl(120, 100%, 40%);">+    /* 3GPP TS 44.018 Table 10.5.2.33b.1 INDEX and COUNT for SI2quater */</span><br><span style="color: hsl(120, 100%, 40%);">+ uint8_t si2q_index; /* distinguish individual SI2quater messages */</span><br><span style="color: hsl(120, 100%, 40%);">+   uint8_t si2q_count; /* si2q_index for the last (highest indexed) individual SI2quater message */</span><br><span style="color: hsl(120, 100%, 40%);">+      /* buffers where we put the pre-computed SI */</span><br><span style="color: hsl(120, 100%, 40%);">+        sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE][SI2Q_MAX_NUM];</span><br><span style="color: hsl(120, 100%, 40%);">+        /* offsets used while generating SI2quater */</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t e_offset;</span><br><span style="color: hsl(120, 100%, 40%);">+      size_t u_offset;</span><br><span style="color: hsl(120, 100%, 40%);">+      /* decoded SI3 rest octets - *unmodified* as received from BSC */</span><br><span style="color: hsl(120, 100%, 40%);">+     struct osmo_gsm48_si_ro_info si3_ro_decoded;</span><br><span style="color: hsl(120, 100%, 40%);">+  /* is SI3 GPRS Indicator currently disabled due to lack of PCU connection? */</span><br><span style="color: hsl(120, 100%, 40%);">+ bool si3_gprs_ind_disabled;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* ip.access Unit ID's have Site/BTS/TRX layout */</span><br><span style="color: hsl(120, 100%, 40%);">+        union {</span><br><span style="color: hsl(120, 100%, 40%);">+               struct {</span><br><span style="color: hsl(120, 100%, 40%);">+                      uint16_t site_id;</span><br><span style="color: hsl(120, 100%, 40%);">+                     uint16_t bts_id;</span><br><span style="color: hsl(120, 100%, 40%);">+                      uint32_t flags;</span><br><span style="color: hsl(120, 100%, 40%);">+                       uint32_t rsl_ip;</span><br><span style="color: hsl(120, 100%, 40%);">+              } ip_access;</span><br><span style="color: hsl(120, 100%, 40%);">+  };</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /* Not entirely sure how ip.access specific this is */</span><br><span style="color: hsl(120, 100%, 40%);">+        struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              struct {</span><br><span style="color: hsl(120, 100%, 40%);">+                      struct gsm_abis_mo mo;</span><br><span style="color: hsl(120, 100%, 40%);">+                        uint16_t nsei;</span><br><span style="color: hsl(120, 100%, 40%);">+                        uint8_t timer[7];</span><br><span style="color: hsl(120, 100%, 40%);">+             } nse;</span><br><span style="color: hsl(120, 100%, 40%);">+                struct {</span><br><span style="color: hsl(120, 100%, 40%);">+                      struct gsm_abis_mo mo;</span><br><span style="color: hsl(120, 100%, 40%);">+                        uint16_t bvci;</span><br><span style="color: hsl(120, 100%, 40%);">+                        uint8_t timer[11];</span><br><span style="color: hsl(120, 100%, 40%);">+                    struct gprs_rlc_cfg rlc_cfg;</span><br><span style="color: hsl(120, 100%, 40%);">+          } cell;</span><br><span style="color: hsl(120, 100%, 40%);">+               struct gsm_bts_gprs_nsvc nsvc[2];</span><br><span style="color: hsl(120, 100%, 40%);">+             uint8_t rac;</span><br><span style="color: hsl(120, 100%, 40%);">+  } gprs;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* transceivers */</span><br><span style="color: hsl(120, 100%, 40%);">+    int num_trx;</span><br><span style="color: hsl(120, 100%, 40%);">+  struct llist_head trx_list;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ struct rate_ctr_group *ctrs;</span><br><span style="color: hsl(120, 100%, 40%);">+  bool supp_meas_toa256;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              /* Interference Boundaries for OML */</span><br><span style="color: hsl(120, 100%, 40%);">+         int16_t boundary[6];</span><br><span style="color: hsl(120, 100%, 40%);">+          uint8_t intave;</span><br><span style="color: hsl(120, 100%, 40%);">+       } interference;</span><br><span style="color: hsl(120, 100%, 40%);">+       unsigned int t200_ms[7];</span><br><span style="color: hsl(120, 100%, 40%);">+      unsigned int t3105_ms;</span><br><span style="color: hsl(120, 100%, 40%);">+        struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              uint8_t overload_period;</span><br><span style="color: hsl(120, 100%, 40%);">+              struct {</span><br><span style="color: hsl(120, 100%, 40%);">+                      /* Input parameters from OML */</span><br><span style="color: hsl(120, 100%, 40%);">+                       uint8_t load_ind_thresh;        /* percent */</span><br><span style="color: hsl(120, 100%, 40%);">+                 uint8_t load_ind_period;        /* seconds */</span><br><span style="color: hsl(120, 100%, 40%);">+                 /* Internal data */</span><br><span style="color: hsl(120, 100%, 40%);">+                   struct osmo_timer_list timer;</span><br><span style="color: hsl(120, 100%, 40%);">+                 unsigned int pch_total;</span><br><span style="color: hsl(120, 100%, 40%);">+                       unsigned int pch_used;</span><br><span style="color: hsl(120, 100%, 40%);">+                } ccch;</span><br><span style="color: hsl(120, 100%, 40%);">+               struct {</span><br><span style="color: hsl(120, 100%, 40%);">+                      /* Input parameters from OML */</span><br><span style="color: hsl(120, 100%, 40%);">+                       int16_t busy_thresh;            /* in dBm */</span><br><span style="color: hsl(120, 100%, 40%);">+                  uint16_t averaging_slots;</span><br><span style="color: hsl(120, 100%, 40%);">+                     /* Internal data */</span><br><span style="color: hsl(120, 100%, 40%);">+                   unsigned int total;     /* total nr */</span><br><span style="color: hsl(120, 100%, 40%);">+                        unsigned int busy;      /* above busy_thresh */</span><br><span style="color: hsl(120, 100%, 40%);">+                       unsigned int access;    /* access bursts */</span><br><span style="color: hsl(120, 100%, 40%);">+           } rach;</span><br><span style="color: hsl(120, 100%, 40%);">+       } load;</span><br><span style="color: hsl(120, 100%, 40%);">+       uint8_t ny1;</span><br><span style="color: hsl(120, 100%, 40%);">+  uint8_t max_ta;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* AGCH queuing */</span><br><span style="color: hsl(120, 100%, 40%);">+    struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              struct llist_head queue;</span><br><span style="color: hsl(120, 100%, 40%);">+              int length;</span><br><span style="color: hsl(120, 100%, 40%);">+           int max_length;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+             int thresh_level;       /* Cleanup threshold in percent of max len */</span><br><span style="color: hsl(120, 100%, 40%);">+         int low_level;          /* Low water mark in percent of max len */</span><br><span style="color: hsl(120, 100%, 40%);">+            int high_level;         /* High water mark in percent of max len */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+         /* TODO: Use a rate counter group instead */</span><br><span style="color: hsl(120, 100%, 40%);">+          uint64_t dropped_msgs;</span><br><span style="color: hsl(120, 100%, 40%);">+                uint64_t merged_msgs;</span><br><span style="color: hsl(120, 100%, 40%);">+         uint64_t rejected_msgs;</span><br><span style="color: hsl(120, 100%, 40%);">+               uint64_t agch_msgs;</span><br><span style="color: hsl(120, 100%, 40%);">+           uint64_t pch_msgs;</span><br><span style="color: hsl(120, 100%, 40%);">+    } agch_queue;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              uint8_t *prim_notif;    /* ETWS primary notification (NULL if none) */</span><br><span style="color: hsl(120, 100%, 40%);">+                ssize_t prim_notif_len; /* Length of prim_notif; expected 56 bytes */</span><br><span style="color: hsl(120, 100%, 40%);">+         uint8_t page_size;</span><br><span style="color: hsl(120, 100%, 40%);">+            uint8_t num_pages;      /* total number of pages */</span><br><span style="color: hsl(120, 100%, 40%);">+           uint8_t next_page;      /* next page number to be sent */</span><br><span style="color: hsl(120, 100%, 40%);">+             bool pni;               /* Primary Notification Identifier */</span><br><span style="color: hsl(120, 100%, 40%);">+ } etws;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     struct paging_state *paging_state;</span><br><span style="color: hsl(120, 100%, 40%);">+    char *bsc_oml_host;</span><br><span style="color: hsl(120, 100%, 40%);">+   struct llist_head oml_queue;</span><br><span style="color: hsl(120, 100%, 40%);">+  unsigned int rtp_jitter_buf_ms;</span><br><span style="color: hsl(120, 100%, 40%);">+       bool rtp_jitter_adaptive;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   uint16_t rtp_port_range_start;</span><br><span style="color: hsl(120, 100%, 40%);">+        uint16_t rtp_port_range_end;</span><br><span style="color: hsl(120, 100%, 40%);">+  uint16_t rtp_port_range_next;</span><br><span style="color: hsl(120, 100%, 40%);">+ int rtp_ip_dscp;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              uint8_t ciphers;        /* flags A5/1==0x1, A5/2==0x2, A5/3==0x4 */</span><br><span style="color: hsl(120, 100%, 40%);">+   } support;</span><br><span style="color: hsl(120, 100%, 40%);">+    struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              uint8_t tc4_ctr;</span><br><span style="color: hsl(120, 100%, 40%);">+      } si;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct gsm_time gsm_time;</span><br><span style="color: hsl(120, 100%, 40%);">+     /* frame number statistics (FN in PH-RTS.ind vs. PH-DATA.ind */</span><br><span style="color: hsl(120, 100%, 40%);">+       struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              int32_t min;            /* minimum observed */</span><br><span style="color: hsl(120, 100%, 40%);">+                int32_t max;            /* maximum observed */</span><br><span style="color: hsl(120, 100%, 40%);">+                int32_t avg256;         /* accumulator */</span><br><span style="color: hsl(120, 100%, 40%);">+             uint32_t avg_count;     /* number of samples accumulated in avg256 */</span><br><span style="color: hsl(120, 100%, 40%);">+         uint32_t avg_window;    /* number of averages in avg_count */</span><br><span style="color: hsl(120, 100%, 40%);">+ } fn_stats;</span><br><span style="color: hsl(120, 100%, 40%);">+   /* Radio Link Timeout counter. -1 disables timeout for</span><br><span style="color: hsl(120, 100%, 40%);">+         * lab/measurement purpose */</span><br><span style="color: hsl(120, 100%, 40%);">+ int radio_link_timeout;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     int ul_power_target;            /* Uplink Rx power target */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* used by the sysmoBTS to adjust band */</span><br><span style="color: hsl(120, 100%, 40%);">+     uint8_t auto_band;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /* State for SMSCB (Cell Broadcast) for BASIC and EXTENDED channel */</span><br><span style="color: hsl(120, 100%, 40%);">+ struct bts_smscb_state smscb_basic;</span><br><span style="color: hsl(120, 100%, 40%);">+   struct bts_smscb_state smscb_extended;</span><br><span style="color: hsl(120, 100%, 40%);">+        int smscb_queue_tgt_len; /* ideal/target queue length */</span><br><span style="color: hsl(120, 100%, 40%);">+      int smscb_queue_max_len; /* maximum queue length */</span><br><span style="color: hsl(120, 100%, 40%);">+   int smscb_queue_hyst; /* hysteresis for CBCH load indications */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    int16_t min_qual_rach;  /* minimum link quality (in centiBels) for Access Bursts */</span><br><span style="color: hsl(120, 100%, 40%);">+   int16_t min_qual_norm;  /* minimum link quality (in centiBels) for Normal Bursts */</span><br><span style="color: hsl(120, 100%, 40%);">+   uint16_t max_ber10k_rach;       /* Maximum permitted RACH BER in 0.01% */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              char *sock_path;</span><br><span style="color: hsl(120, 100%, 40%);">+      } pcu;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      struct osmo_fsm_inst *shutdown_fi; /* FSM instance to manage shutdown procedure during process exit */</span><br><span style="color: hsl(120, 100%, 40%);">+        struct osmo_tdef *T_defs; /* Timer defines */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       void *model_priv; /* Allocated by bts_model, contains model specific data pointer */</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+extern const struct value_string bts_impl_flag_desc[];</span><br><span> extern void *tall_bts_ctx;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_BTS_SI2Q(bts, i)   (struct gsm48_system_information_type_2quater *)((bts)->si_buf[SYSINFO_TYPE_2quater][i])</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_BTS_HAS_SI(bts, i) ((bts)->si_valid & (1 << i))</span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_BTS_SI(bts, i)     (void *)((bts)->si_buf[i][0])</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm_bts *gsm_bts_alloc(void *talloc_ctx, uint8_t bts_num);</span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> int bts_init(struct gsm_bts *bts);</span><br><span> int bts_trx_init(struct gsm_bts_trx *trx);</span><br><span> void bts_shutdown(struct gsm_bts *bts, const char *reason);</span><br><span>@@ -39,7 +330,7 @@</span><br><span> int bts_agch_max_queue_length(int T, int bcch_conf);</span><br><span> int bts_ccch_copy_msg(struct gsm_bts *bts, uint8_t *out_buf, struct gsm_time *gt,</span><br><span>                    int is_ag_res);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+int bts_supports_cipher(struct gsm_bts *bts, int rsl_cipher);</span><br><span> uint8_t *bts_sysinfo_get(struct gsm_bts *bts, const struct gsm_time *g_time);</span><br><span> void regenerate_si3_restoctets(struct gsm_bts *bts);</span><br><span> uint8_t *lchan_sacch_get(struct gsm_lchan *lchan);</span><br><span>@@ -60,4 +351,7 @@</span><br><span> </span><br><span> int32_t bts_get_avg_fn_advance(struct gsm_bts *bts);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* return the gsm_lchan for the CBCH (if it exists at all) */</span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #endif /* _BTS_H */</span><br><span>diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h</span><br><span>index 2e8ff46..0bb7761 100644</span><br><span>--- a/include/osmo-bts/gsm_data.h</span><br><span>+++ b/include/osmo-bts/gsm_data.h</span><br><span>@@ -386,59 +386,8 @@</span><br><span>   struct gsm_bts_trx_ts ts[TRX_NR_TS];</span><br><span> };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_BTS_SI2Q(bts, i)   (struct gsm48_system_information_type_2quater *)((bts)->si_buf[SYSINFO_TYPE_2quater][i])</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_BTS_HAS_SI(bts, i) ((bts)->si_valid & (1 << i))</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_BTS_SI(bts, i)     (void *)((bts)->si_buf[i][0])</span><br><span> #define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i][0])</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-enum gsm_bts_type_variant {</span><br><span style="color: hsl(0, 100%, 40%);">-     BTS_UNKNOWN,</span><br><span style="color: hsl(0, 100%, 40%);">-    BTS_OSMO_LITECELL15,</span><br><span style="color: hsl(0, 100%, 40%);">-        BTS_OSMO_OC2G,</span><br><span style="color: hsl(0, 100%, 40%);">-      BTS_OSMO_OCTPHY,</span><br><span style="color: hsl(0, 100%, 40%);">-        BTS_OSMO_SYSMO,</span><br><span style="color: hsl(0, 100%, 40%);">- BTS_OSMO_TRX,</span><br><span style="color: hsl(0, 100%, 40%);">-   BTS_OSMO_VIRTUAL,</span><br><span style="color: hsl(0, 100%, 40%);">-       BTS_OSMO_OMLDUMMY,</span><br><span style="color: hsl(0, 100%, 40%);">-      _NUM_BTS_VARIANT</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/* Used by OML layer for BTS Attribute reporting */</span><br><span style="color: hsl(0, 100%, 40%);">-enum bts_attribute {</span><br><span style="color: hsl(0, 100%, 40%);">-       BTS_TYPE_VARIANT,</span><br><span style="color: hsl(0, 100%, 40%);">-       BTS_SUB_MODEL,</span><br><span style="color: hsl(0, 100%, 40%);">-  TRX_PHY_VERSION,</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/* BTS implementation flags (internal use, not exposed via OML) */</span><br><span style="color: hsl(0, 100%, 40%);">-#define bts_internal_flag_get(bts, flag) \</span><br><span style="color: hsl(0, 100%, 40%);">-  ((bts->flags & (typeof(bts->flags)) flag) != 0)</span><br><span style="color: hsl(0, 100%, 40%);">-#define bts_internal_flag_set(bts, flag) \</span><br><span style="color: hsl(0, 100%, 40%);">-     bts->flags |= (typeof(bts->flags)) flag</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/* TODO: add a brief description of this flag */</span><br><span style="color: hsl(0, 100%, 40%);">-#define BTS_INTERNAL_FLAG_MS_PWR_CTRL_DSP          (1 << 0)</span><br><span style="color: hsl(0, 100%, 40%);">-/* When this flag is set then the measurement data is included in</span><br><span style="color: hsl(0, 100%, 40%);">- * (PRIM_PH_DATA) and struct ph_tch_param (PRIM_TCH). Otherwise the</span><br><span style="color: hsl(0, 100%, 40%);">- * measurement data is passed using a separate MPH INFO MEAS IND.</span><br><span style="color: hsl(0, 100%, 40%);">- * (See also ticket: OS#2977) */</span><br><span style="color: hsl(0, 100%, 40%);">-#define BTS_INTERNAL_FLAG_MEAS_PAYLOAD_COMB          (1 << 1)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-extern const struct value_string bts_impl_flag_desc[];</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-struct gsm_bts_gprs_nsvc {</span><br><span style="color: hsl(0, 100%, 40%);">-  struct gsm_bts *bts;</span><br><span style="color: hsl(0, 100%, 40%);">-    /* data read via VTY config file, to configure the BTS</span><br><span style="color: hsl(0, 100%, 40%);">-   * via OML from BSC */</span><br><span style="color: hsl(0, 100%, 40%);">-  int id;</span><br><span style="color: hsl(0, 100%, 40%);">- uint16_t nsvci;</span><br><span style="color: hsl(0, 100%, 40%);">- uint16_t local_port;    /* on the BTS */</span><br><span style="color: hsl(0, 100%, 40%);">-        uint16_t remote_port;   /* on the SGSN */</span><br><span style="color: hsl(0, 100%, 40%);">-       uint32_t remote_ip;     /* on the SGSN */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       struct gsm_abis_mo mo;</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> enum gprs_rlc_par {</span><br><span>      RLC_T3142,</span><br><span>   RLC_T3169,</span><br><span>@@ -471,257 +420,13 @@</span><br><span>  _NUM_GRPS_CS</span><br><span> };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-struct gprs_rlc_cfg {</span><br><span style="color: hsl(0, 100%, 40%);">-     uint16_t parameter[_NUM_RLC_PAR];</span><br><span style="color: hsl(0, 100%, 40%);">-       struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                uint16_t repeat_time; /* ms */</span><br><span style="color: hsl(0, 100%, 40%);">-          uint8_t repeat_count;</span><br><span style="color: hsl(0, 100%, 40%);">-   } paging;</span><br><span style="color: hsl(0, 100%, 40%);">-       uint32_t cs_mask; /* bitmask of gprs_cs */</span><br><span style="color: hsl(0, 100%, 40%);">-      uint8_t initial_cs;</span><br><span style="color: hsl(0, 100%, 40%);">-     uint8_t initial_mcs;</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-struct bts_smscb_state {</span><br><span style="color: hsl(0, 100%, 40%);">-  struct llist_head queue; /* list of struct smscb_msg */</span><br><span style="color: hsl(0, 100%, 40%);">- int queue_len;</span><br><span style="color: hsl(0, 100%, 40%);">-  struct rate_ctr_group *ctrs;</span><br><span style="color: hsl(0, 100%, 40%);">-    struct smscb_msg *cur_msg; /* current SMS-CB */</span><br><span style="color: hsl(0, 100%, 40%);">- struct smscb_msg *default_msg; /* default broadcast message; NULL if none */</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /* The amount of time within which a sudden disconnect of a newly established</span><br><span>  * OML connection will cause a special warning to be logged. */</span><br><span> #define OSMO_BTS_OML_CONN_EARLY_DISCONNECT 10      /* in seconds */</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* One BTS */</span><br><span style="color: hsl(0, 100%, 40%);">-struct gsm_bts {</span><br><span style="color: hsl(0, 100%, 40%);">-      /* list header in net->bts_list */</span><br><span style="color: hsl(0, 100%, 40%);">-   struct llist_head list;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* number of the BTS in network */</span><br><span style="color: hsl(0, 100%, 40%);">-      uint8_t nr;</span><br><span style="color: hsl(0, 100%, 40%);">-     /* human readable name / description */</span><br><span style="color: hsl(0, 100%, 40%);">- char *description;</span><br><span style="color: hsl(0, 100%, 40%);">-      /* Cell Identity */</span><br><span style="color: hsl(0, 100%, 40%);">-     uint16_t cell_identity;</span><br><span style="color: hsl(0, 100%, 40%);">- /* location area code of this BTS */</span><br><span style="color: hsl(0, 100%, 40%);">-    uint16_t location_area_code;</span><br><span style="color: hsl(0, 100%, 40%);">-    /* Base Station Identification Code (BSIC), lower 3 bits is BCC,</span><br><span style="color: hsl(0, 100%, 40%);">-         * which is used as TSC for the CCCH */</span><br><span style="color: hsl(0, 100%, 40%);">- uint8_t bsic;</span><br><span style="color: hsl(0, 100%, 40%);">-   /* type of BTS */</span><br><span style="color: hsl(0, 100%, 40%);">-       enum gsm_bts_type_variant variant;</span><br><span style="color: hsl(0, 100%, 40%);">-      enum gsm_band band;</span><br><span style="color: hsl(0, 100%, 40%);">-     char version[MAX_VERSION_LENGTH];</span><br><span style="color: hsl(0, 100%, 40%);">-       char sub_model[MAX_VERSION_LENGTH];</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     /* public features of a given BTS (set/reported via OML) */</span><br><span style="color: hsl(0, 100%, 40%);">-     struct bitvec *features;</span><br><span style="color: hsl(0, 100%, 40%);">-        /* implementation flags of a given BTS (not exposed via OML) */</span><br><span style="color: hsl(0, 100%, 40%);">- uint16_t flags;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* Connected PCU version (if any) */</span><br><span style="color: hsl(0, 100%, 40%);">-    char pcu_version[MAX_VERSION_LENGTH];</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   /* maximum Tx power that the MS is permitted to use in this cell */</span><br><span style="color: hsl(0, 100%, 40%);">-     int ms_max_power;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* how do we talk OML with this TRX? */</span><br><span style="color: hsl(0, 100%, 40%);">- struct e1inp_sign_link *oml_link;</span><br><span style="color: hsl(0, 100%, 40%);">-       struct timespec oml_conn_established_timestamp;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* Abis network management O&M handle */</span><br><span style="color: hsl(0, 100%, 40%);">-    struct gsm_abis_mo mo;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* number of this BTS on given E1 link */</span><br><span style="color: hsl(0, 100%, 40%);">-       uint8_t bts_nr;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* DTX features of this BTS */</span><br><span style="color: hsl(0, 100%, 40%);">-  bool dtxd;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* CCCH is on C0 */</span><br><span style="color: hsl(0, 100%, 40%);">-     struct gsm_bts_trx *c0;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                struct gsm_abis_mo mo;</span><br><span style="color: hsl(0, 100%, 40%);">-  } site_mgr;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     /* bitmask of all SI that are present/valid in si_buf */</span><br><span style="color: hsl(0, 100%, 40%);">-        uint32_t si_valid;</span><br><span style="color: hsl(0, 100%, 40%);">-      /* 3GPP TS 44.018 Table 10.5.2.33b.1 INDEX and COUNT for SI2quater */</span><br><span style="color: hsl(0, 100%, 40%);">-   uint8_t si2q_index; /* distinguish individual SI2quater messages */</span><br><span style="color: hsl(0, 100%, 40%);">-     uint8_t si2q_count; /* si2q_index for the last (highest indexed) individual SI2quater message */</span><br><span style="color: hsl(0, 100%, 40%);">-        /* buffers where we put the pre-computed SI */</span><br><span style="color: hsl(0, 100%, 40%);">-  sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE][SI2Q_MAX_NUM];</span><br><span style="color: hsl(0, 100%, 40%);">-  /* offsets used while generating SI2quater */</span><br><span style="color: hsl(0, 100%, 40%);">-   size_t e_offset;</span><br><span style="color: hsl(0, 100%, 40%);">-        size_t u_offset;</span><br><span style="color: hsl(0, 100%, 40%);">-        /* decoded SI3 rest octets - *unmodified* as received from BSC */</span><br><span style="color: hsl(0, 100%, 40%);">-       struct osmo_gsm48_si_ro_info si3_ro_decoded;</span><br><span style="color: hsl(0, 100%, 40%);">-    /* is SI3 GPRS Indicator currently disabled due to lack of PCU connection? */</span><br><span style="color: hsl(0, 100%, 40%);">-   bool si3_gprs_ind_disabled;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     /* ip.access Unit ID's have Site/BTS/TRX layout */</span><br><span style="color: hsl(0, 100%, 40%);">-  union {</span><br><span style="color: hsl(0, 100%, 40%);">-         struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                        uint16_t site_id;</span><br><span style="color: hsl(0, 100%, 40%);">-                       uint16_t bts_id;</span><br><span style="color: hsl(0, 100%, 40%);">-                        uint32_t flags;</span><br><span style="color: hsl(0, 100%, 40%);">-                 uint32_t rsl_ip;</span><br><span style="color: hsl(0, 100%, 40%);">-                } ip_access;</span><br><span style="color: hsl(0, 100%, 40%);">-    };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* Not entirely sure how ip.access specific this is */</span><br><span style="color: hsl(0, 100%, 40%);">-  struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                        struct gsm_abis_mo mo;</span><br><span style="color: hsl(0, 100%, 40%);">-                  uint16_t nsei;</span><br><span style="color: hsl(0, 100%, 40%);">-                  uint8_t timer[7];</span><br><span style="color: hsl(0, 100%, 40%);">-               } nse;</span><br><span style="color: hsl(0, 100%, 40%);">-          struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                        struct gsm_abis_mo mo;</span><br><span style="color: hsl(0, 100%, 40%);">-                  uint16_t bvci;</span><br><span style="color: hsl(0, 100%, 40%);">-                  uint8_t timer[11];</span><br><span style="color: hsl(0, 100%, 40%);">-                      struct gprs_rlc_cfg rlc_cfg;</span><br><span style="color: hsl(0, 100%, 40%);">-            } cell;</span><br><span style="color: hsl(0, 100%, 40%);">-         struct gsm_bts_gprs_nsvc nsvc[2];</span><br><span style="color: hsl(0, 100%, 40%);">-               uint8_t rac;</span><br><span style="color: hsl(0, 100%, 40%);">-    } gprs;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* transceivers */</span><br><span style="color: hsl(0, 100%, 40%);">-      int num_trx;</span><br><span style="color: hsl(0, 100%, 40%);">-    struct llist_head trx_list;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     struct rate_ctr_group *ctrs;</span><br><span style="color: hsl(0, 100%, 40%);">-    bool supp_meas_toa256;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                /* Interference Boundaries for OML */</span><br><span style="color: hsl(0, 100%, 40%);">-           int16_t boundary[6];</span><br><span style="color: hsl(0, 100%, 40%);">-            uint8_t intave;</span><br><span style="color: hsl(0, 100%, 40%);">- } interference;</span><br><span style="color: hsl(0, 100%, 40%);">- unsigned int t200_ms[7];</span><br><span style="color: hsl(0, 100%, 40%);">-        unsigned int t3105_ms;</span><br><span style="color: hsl(0, 100%, 40%);">-  struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                uint8_t overload_period;</span><br><span style="color: hsl(0, 100%, 40%);">-                struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                        /* Input parameters from OML */</span><br><span style="color: hsl(0, 100%, 40%);">-                 uint8_t load_ind_thresh;        /* percent */</span><br><span style="color: hsl(0, 100%, 40%);">-                   uint8_t load_ind_period;        /* seconds */</span><br><span style="color: hsl(0, 100%, 40%);">-                   /* Internal data */</span><br><span style="color: hsl(0, 100%, 40%);">-                     struct osmo_timer_list timer;</span><br><span style="color: hsl(0, 100%, 40%);">-                   unsigned int pch_total;</span><br><span style="color: hsl(0, 100%, 40%);">-                 unsigned int pch_used;</span><br><span style="color: hsl(0, 100%, 40%);">-          } ccch;</span><br><span style="color: hsl(0, 100%, 40%);">-         struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                        /* Input parameters from OML */</span><br><span style="color: hsl(0, 100%, 40%);">-                 int16_t busy_thresh;            /* in dBm */</span><br><span style="color: hsl(0, 100%, 40%);">-                    uint16_t averaging_slots;</span><br><span style="color: hsl(0, 100%, 40%);">-                       /* Internal data */</span><br><span style="color: hsl(0, 100%, 40%);">-                     unsigned int total;     /* total nr */</span><br><span style="color: hsl(0, 100%, 40%);">-                  unsigned int busy;      /* above busy_thresh */</span><br><span style="color: hsl(0, 100%, 40%);">-                 unsigned int access;    /* access bursts */</span><br><span style="color: hsl(0, 100%, 40%);">-             } rach;</span><br><span style="color: hsl(0, 100%, 40%);">- } load;</span><br><span style="color: hsl(0, 100%, 40%);">- uint8_t ny1;</span><br><span style="color: hsl(0, 100%, 40%);">-    uint8_t max_ta;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* AGCH queuing */</span><br><span style="color: hsl(0, 100%, 40%);">-      struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                struct llist_head queue;</span><br><span style="color: hsl(0, 100%, 40%);">-                int length;</span><br><span style="color: hsl(0, 100%, 40%);">-             int max_length;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-         int thresh_level;       /* Cleanup threshold in percent of max len */</span><br><span style="color: hsl(0, 100%, 40%);">-           int low_level;          /* Low water mark in percent of max len */</span><br><span style="color: hsl(0, 100%, 40%);">-              int high_level;         /* High water mark in percent of max len */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-             /* TODO: Use a rate counter group instead */</span><br><span style="color: hsl(0, 100%, 40%);">-            uint64_t dropped_msgs;</span><br><span style="color: hsl(0, 100%, 40%);">-          uint64_t merged_msgs;</span><br><span style="color: hsl(0, 100%, 40%);">-           uint64_t rejected_msgs;</span><br><span style="color: hsl(0, 100%, 40%);">-         uint64_t agch_msgs;</span><br><span style="color: hsl(0, 100%, 40%);">-             uint64_t pch_msgs;</span><br><span style="color: hsl(0, 100%, 40%);">-      } agch_queue;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                uint8_t *prim_notif;    /* ETWS primary notification (NULL if none) */</span><br><span style="color: hsl(0, 100%, 40%);">-          ssize_t prim_notif_len; /* Length of prim_notif; expected 56 bytes */</span><br><span style="color: hsl(0, 100%, 40%);">-           uint8_t page_size;</span><br><span style="color: hsl(0, 100%, 40%);">-              uint8_t num_pages;      /* total number of pages */</span><br><span style="color: hsl(0, 100%, 40%);">-             uint8_t next_page;      /* next page number to be sent */</span><br><span style="color: hsl(0, 100%, 40%);">-               bool pni;               /* Primary Notification Identifier */</span><br><span style="color: hsl(0, 100%, 40%);">-   } etws;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- struct paging_state *paging_state;</span><br><span style="color: hsl(0, 100%, 40%);">-      char *bsc_oml_host;</span><br><span style="color: hsl(0, 100%, 40%);">-     struct llist_head oml_queue;</span><br><span style="color: hsl(0, 100%, 40%);">-    unsigned int rtp_jitter_buf_ms;</span><br><span style="color: hsl(0, 100%, 40%);">- bool rtp_jitter_adaptive;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       uint16_t rtp_port_range_start;</span><br><span style="color: hsl(0, 100%, 40%);">-  uint16_t rtp_port_range_end;</span><br><span style="color: hsl(0, 100%, 40%);">-    uint16_t rtp_port_range_next;</span><br><span style="color: hsl(0, 100%, 40%);">-   int rtp_ip_dscp;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                uint8_t ciphers;        /* flags A5/1==0x1, A5/2==0x2, A5/3==0x4 */</span><br><span style="color: hsl(0, 100%, 40%);">-     } support;</span><br><span style="color: hsl(0, 100%, 40%);">-      struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                uint8_t tc4_ctr;</span><br><span style="color: hsl(0, 100%, 40%);">-        } si;</span><br><span style="color: hsl(0, 100%, 40%);">-   struct gsm_time gsm_time;</span><br><span style="color: hsl(0, 100%, 40%);">-       /* frame number statistics (FN in PH-RTS.ind vs. PH-DATA.ind */</span><br><span style="color: hsl(0, 100%, 40%);">- struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                int32_t min;            /* minimum observed */</span><br><span style="color: hsl(0, 100%, 40%);">-          int32_t max;            /* maximum observed */</span><br><span style="color: hsl(0, 100%, 40%);">-          int32_t avg256;         /* accumulator */</span><br><span style="color: hsl(0, 100%, 40%);">-               uint32_t avg_count;     /* number of samples accumulated in avg256 */</span><br><span style="color: hsl(0, 100%, 40%);">-           uint32_t avg_window;    /* number of averages in avg_count */</span><br><span style="color: hsl(0, 100%, 40%);">-   } fn_stats;</span><br><span style="color: hsl(0, 100%, 40%);">-     /* Radio Link Timeout counter. -1 disables timeout for</span><br><span style="color: hsl(0, 100%, 40%);">-   * lab/measurement purpose */</span><br><span style="color: hsl(0, 100%, 40%);">-   int radio_link_timeout;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- int ul_power_target;            /* Uplink Rx power target */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    /* used by the sysmoBTS to adjust band */</span><br><span style="color: hsl(0, 100%, 40%);">-       uint8_t auto_band;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* State for SMSCB (Cell Broadcast) for BASIC and EXTENDED channel */</span><br><span style="color: hsl(0, 100%, 40%);">-   struct bts_smscb_state smscb_basic;</span><br><span style="color: hsl(0, 100%, 40%);">-     struct bts_smscb_state smscb_extended;</span><br><span style="color: hsl(0, 100%, 40%);">-  int smscb_queue_tgt_len; /* ideal/target queue length */</span><br><span style="color: hsl(0, 100%, 40%);">-        int smscb_queue_max_len; /* maximum queue length */</span><br><span style="color: hsl(0, 100%, 40%);">-     int smscb_queue_hyst; /* hysteresis for CBCH load indications */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        int16_t min_qual_rach;  /* minimum link quality (in centiBels) for Access Bursts */</span><br><span style="color: hsl(0, 100%, 40%);">-     int16_t min_qual_norm;  /* minimum link quality (in centiBels) for Normal Bursts */</span><br><span style="color: hsl(0, 100%, 40%);">-     uint16_t max_ber10k_rach;       /* Maximum permitted RACH BER in 0.01% */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       struct {</span><br><span style="color: hsl(0, 100%, 40%);">-                char *sock_path;</span><br><span style="color: hsl(0, 100%, 40%);">-        } pcu;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  struct osmo_fsm_inst *shutdown_fi; /* FSM instance to manage shutdown procedure during process exit */</span><br><span style="color: hsl(0, 100%, 40%);">-  struct osmo_tdef *T_defs; /* Timer defines */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   void *model_priv; /* Allocated by bts_model, contains model specific data pointer */</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-struct gsm_bts *gsm_bts_alloc(void *talloc_ctx, uint8_t bts_num);</span><br><span style="color: hsl(0, 100%, 40%);">-struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);</span><br><span> struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-enum bts_attribute str2btsattr(const char *s);</span><br><span style="color: hsl(0, 100%, 40%);">-const char *btsatttr2str(enum bts_attribute v);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-enum gsm_bts_type_variant str2btsvariant(const char *arg);</span><br><span style="color: hsl(0, 100%, 40%);">-const char *btsvariant2str(enum gsm_bts_type_variant v);</span><br><span> </span><br><span> extern const struct value_string gsm_pchant_names[13];</span><br><span> extern const struct value_string gsm_pchant_descs[13];</span><br><span>@@ -743,18 +448,9 @@</span><br><span> uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan,</span><br><span>                                 enum gsm_phys_chan_config as_pchan);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* return the gsm_lchan for the CBCH (if it exists at all) */</span><br><span style="color: hsl(0, 100%, 40%);">-struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> #define BSIC2BCC(bsic) ((bsic) & 0x3)</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-     if (ts->tsc != -1)</span><br><span style="color: hsl(0, 100%, 40%);">-           return ts->tsc;</span><br><span style="color: hsl(0, 100%, 40%);">-      else</span><br><span style="color: hsl(0, 100%, 40%);">-            return ts->trx->bts->bsic & 7;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts);</span><br><span> </span><br><span> struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,</span><br><span>                                  int *rc);</span><br><span>@@ -773,10 +469,6 @@</span><br><span> /* cipher code */</span><br><span> #define CIPHER_A5(x) (1 << (x-1))</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-int bts_supports_cipher(struct gsm_bts *bts, int rsl_cipher);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> bool ts_is_pdch(const struct gsm_bts_trx_ts *ts);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-int bts_model_check_cm_mode(enum gsm_phys_chan_config pchan, enum gsm48_chan_mode cm);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> #endif /* _GSM_DATA_H */</span><br><span>diff --git a/src/common/bts.c b/src/common/bts.c</span><br><span>index dccb098..2f6a700 100644</span><br><span>--- a/src/common/bts.c</span><br><span>+++ b/src/common/bts.c</span><br><span>@@ -32,6 +32,7 @@</span><br><span> #include <osmocom/core/timer.h></span><br><span> #include <osmocom/core/msgb.h></span><br><span> #include <osmocom/core/talloc.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/tdef.h></span><br><span> #include <osmocom/core/stats.h></span><br><span> #include <osmocom/core/rate_ctr.h></span><br><span> #include <osmocom/gsm/protocol/gsm_12_21.h></span><br><span>@@ -50,6 +51,7 @@</span><br><span> #include <osmo-bts/signal.h></span><br><span> #include <osmo-bts/dtx_dl_amr_fsm.h></span><br><span> #include <osmo-bts/cbch.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmo-bts/bts_shutdown_fsm.h></span><br><span> </span><br><span> #define MIN_QUAL_RACH       50 /* minimum link quality (in centiBels) for Access Bursts */</span><br><span> #define MIN_QUAL_NORM         -5 /* minimum link quality (in centiBels) for Normal Bursts */</span><br><span>@@ -122,6 +124,152 @@</span><br><span>      cbch_ctr_desc</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static struct osmo_tdef bts_T_defs[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+     /* T-1: FIXME: Ideally should be dynamically calculated per trx at</span><br><span style="color: hsl(120, 100%, 40%);">+     * shutdown start based on params below, and highest trx value taken:</span><br><span style="color: hsl(120, 100%, 40%);">+  * + VTY's power-ramp step-interval.</span><br><span style="color: hsl(120, 100%, 40%);">+       * + Amount of steps needed (taking into account how many dB each step moves).</span><br><span style="color: hsl(120, 100%, 40%);">+         * + Extra time to get response back for each step.</span><br><span style="color: hsl(120, 100%, 40%);">+    * For now we simply give 5 mins, which should be enough for any</span><br><span style="color: hsl(120, 100%, 40%);">+       * acceptable setup, while still ensuring will timeout at some point if</span><br><span style="color: hsl(120, 100%, 40%);">+        * something fails in the ramp down procedure.</span><br><span style="color: hsl(120, 100%, 40%);">+         */</span><br><span style="color: hsl(120, 100%, 40%);">+   { .T=-1, .default_val=300, .desc="Time after which osmo-bts exits if regular ramp down during shut down process does not finish (s)" },</span><br><span style="color: hsl(120, 100%, 40%);">+     { .T=-2, .default_val=3, .desc="Time after which osmo-bts exits if requesting transceivers to stop during shut down process does not finish (s)" },</span><br><span style="color: hsl(120, 100%, 40%);">+ {}</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static const uint8_t bts_nse_timer_default[] = { 3, 3, 3, 3, 30, 3, 10 };</span><br><span style="color: hsl(120, 100%, 40%);">+static const uint8_t bts_cell_timer_default[] =</span><br><span style="color: hsl(120, 100%, 40%);">+                          { 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 };</span><br><span style="color: hsl(120, 100%, 40%);">+static const struct gprs_rlc_cfg rlc_cfg_default = {</span><br><span style="color: hsl(120, 100%, 40%);">+ .parameter = {</span><br><span style="color: hsl(120, 100%, 40%);">+                [RLC_T3142] = 20,</span><br><span style="color: hsl(120, 100%, 40%);">+             [RLC_T3169] = 5,</span><br><span style="color: hsl(120, 100%, 40%);">+              [RLC_T3191] = 5,</span><br><span style="color: hsl(120, 100%, 40%);">+              [RLC_T3193] = 160, /* 10ms */</span><br><span style="color: hsl(120, 100%, 40%);">+         [RLC_T3195] = 5,</span><br><span style="color: hsl(120, 100%, 40%);">+              [RLC_N3101] = 10,</span><br><span style="color: hsl(120, 100%, 40%);">+             [RLC_N3103] = 4,</span><br><span style="color: hsl(120, 100%, 40%);">+              [RLC_N3105] = 8,</span><br><span style="color: hsl(120, 100%, 40%);">+              [CV_COUNTDOWN] = 15,</span><br><span style="color: hsl(120, 100%, 40%);">+          [T_DL_TBF_EXT] = 250 * 10, /* ms */</span><br><span style="color: hsl(120, 100%, 40%);">+           [T_UL_TBF_EXT] = 250 * 10, /* ms */</span><br><span style="color: hsl(120, 100%, 40%);">+   },</span><br><span style="color: hsl(120, 100%, 40%);">+    .paging = {</span><br><span style="color: hsl(120, 100%, 40%);">+           .repeat_time = 5 * 50, /* ms */</span><br><span style="color: hsl(120, 100%, 40%);">+               .repeat_count = 3,</span><br><span style="color: hsl(120, 100%, 40%);">+    },</span><br><span style="color: hsl(120, 100%, 40%);">+    .cs_mask = 0x1fff,</span><br><span style="color: hsl(120, 100%, 40%);">+    .initial_cs = 2,</span><br><span style="color: hsl(120, 100%, 40%);">+      .initial_mcs = 6,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+const struct value_string osmo_bts_variant_names[_NUM_BTS_VARIANT + 1] = {</span><br><span style="color: hsl(120, 100%, 40%);">+   { BTS_UNKNOWN,          "unknown" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { BTS_OSMO_LITECELL15,  "osmo-bts-lc15" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { BTS_OSMO_OC2G,        "osmo-bts-oc2g" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { BTS_OSMO_OCTPHY,      "osmo-bts-octphy" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { BTS_OSMO_SYSMO,       "osmo-bts-sysmo" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { BTS_OSMO_TRX,         "osmo-bts-trx" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { BTS_OSMO_VIRTUAL,     "osmo-bts-virtual" },</span><br><span style="color: hsl(120, 100%, 40%);">+       { BTS_OSMO_OMLDUMMY,    "osmo-bts-omldummy" },</span><br><span style="color: hsl(120, 100%, 40%);">+      { 0, NULL }</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+const char *btsvariant2str(enum gsm_bts_type_variant v)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ return get_value_string(osmo_bts_variant_names, v);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+const struct value_string bts_attribute_names[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_VALUE_STRING(BTS_TYPE_VARIANT),</span><br><span style="color: hsl(120, 100%, 40%);">+  OSMO_VALUE_STRING(BTS_SUB_MODEL),</span><br><span style="color: hsl(120, 100%, 40%);">+     OSMO_VALUE_STRING(TRX_PHY_VERSION),</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0, NULL }</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+const char *btsatttr2str(enum bts_attribute v)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  return get_value_string(bts_attribute_names, v);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+const struct value_string bts_impl_flag_desc[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+     { BTS_INTERNAL_FLAG_MS_PWR_CTRL_DSP,    "DSP/HW based MS Power Control Loop" },</span><br><span style="color: hsl(120, 100%, 40%);">+     { BTS_INTERNAL_FLAG_MEAS_PAYLOAD_COMB,  "Measurement and Payload data combined" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0, NULL }</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm_bts *gsm_bts_alloc(void *ctx, uint8_t bts_num)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       struct gsm_bts *bts = talloc_zero(ctx, struct gsm_bts);</span><br><span style="color: hsl(120, 100%, 40%);">+       int i;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      if (!bts)</span><br><span style="color: hsl(120, 100%, 40%);">+             return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        bts->nr = bts_num;</span><br><span style="color: hsl(120, 100%, 40%);">+ bts->num_trx = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+  INIT_LLIST_HEAD(&bts->trx_list);</span><br><span style="color: hsl(120, 100%, 40%);">+       bts->ms_max_power = 15;      /* dBm */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   bts->T_defs = bts_T_defs;</span><br><span style="color: hsl(120, 100%, 40%);">+  osmo_tdefs_reset(bts->T_defs);</span><br><span style="color: hsl(120, 100%, 40%);">+     bts->shutdown_fi = osmo_fsm_inst_alloc(&bts_shutdown_fsm, bts, bts,</span><br><span style="color: hsl(120, 100%, 40%);">+                                           LOGL_INFO, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+      osmo_fsm_inst_update_id_f(bts->shutdown_fi, "bts%d", bts->nr);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      gsm_mo_init(&bts->mo, bts, NM_OC_BTS,</span><br><span style="color: hsl(120, 100%, 40%);">+                  bts->nr, 0xff, 0xff);</span><br><span style="color: hsl(120, 100%, 40%);">+      gsm_mo_init(&bts->site_mgr.mo, bts, NM_OC_SITE_MANAGER,</span><br><span style="color: hsl(120, 100%, 40%);">+                        0xff, 0xff, 0xff);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+              bts->gprs.nsvc[i].bts = bts;</span><br><span style="color: hsl(120, 100%, 40%);">+               bts->gprs.nsvc[i].id = i;</span><br><span style="color: hsl(120, 100%, 40%);">+          gsm_mo_init(&bts->gprs.nsvc[i].mo, bts, NM_OC_GPRS_NSVC,</span><br><span style="color: hsl(120, 100%, 40%);">+                               bts->nr, i, 0xff);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+     memcpy(&bts->gprs.nse.timer, bts_nse_timer_default,</span><br><span style="color: hsl(120, 100%, 40%);">+            sizeof(bts->gprs.nse.timer));</span><br><span style="color: hsl(120, 100%, 40%);">+      gsm_mo_init(&bts->gprs.nse.mo, bts, NM_OC_GPRS_NSE,</span><br><span style="color: hsl(120, 100%, 40%);">+                    bts->nr, 0xff, 0xff);</span><br><span style="color: hsl(120, 100%, 40%);">+      memcpy(&bts->gprs.cell.timer, bts_cell_timer_default,</span><br><span style="color: hsl(120, 100%, 40%);">+          sizeof(bts->gprs.cell.timer));</span><br><span style="color: hsl(120, 100%, 40%);">+     gsm_mo_init(&bts->gprs.cell.mo, bts, NM_OC_GPRS_CELL,</span><br><span style="color: hsl(120, 100%, 40%);">+                  bts->nr, 0xff, 0xff);</span><br><span style="color: hsl(120, 100%, 40%);">+      memcpy(&bts->gprs.cell.rlc_cfg, &rlc_cfg_default,</span><br><span style="color: hsl(120, 100%, 40%);">+          sizeof(bts->gprs.cell.rlc_cfg));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* create our primary TRX. It will be initialized during bts_init() */</span><br><span style="color: hsl(120, 100%, 40%);">+        bts->c0 = gsm_bts_trx_alloc(bts);</span><br><span style="color: hsl(120, 100%, 40%);">+  if (!bts->c0) {</span><br><span style="color: hsl(120, 100%, 40%);">+            talloc_free(bts);</span><br><span style="color: hsl(120, 100%, 40%);">+             return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+     bts->c0->ts[0].pchan = GSM_PCHAN_CCCH_SDCCH4;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ bts->features = bitvec_alloc(MAX_BTS_FEATURES / 8, bts);</span><br><span style="color: hsl(120, 100%, 40%);">+   OSMO_ASSERT(bts->features != NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      return bts;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    struct gsm_bts *bts;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        if (num >= net->num_bts)</span><br><span style="color: hsl(120, 100%, 40%);">+                return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        llist_for_each_entry(bts, &net->bts_list, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+              if (bts->nr == num)</span><br><span style="color: hsl(120, 100%, 40%);">+                        return bts;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Initialize the BTS data structures, called before config</span><br><span>  * file reading */</span><br><span> int bts_init(struct gsm_bts *bts)</span><br><span>@@ -817,3 +965,24 @@</span><br><span> </span><br><span>       return 0;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* return the gsm_lchan for the CBCH (if it exists at all) */</span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   struct gsm_lchan *lchan = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+       struct gsm_bts_trx *trx = bts->c0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       if (trx->ts[0].pchan == GSM_PCHAN_CCCH_SDCCH4_CBCH)</span><br><span style="color: hsl(120, 100%, 40%);">+                lchan = &trx->ts[0].lchan[2];</span><br><span style="color: hsl(120, 100%, 40%);">+  else {</span><br><span style="color: hsl(120, 100%, 40%);">+                int i;</span><br><span style="color: hsl(120, 100%, 40%);">+                for (i = 0; i < 8; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  if (trx->ts[i].pchan == GSM_PCHAN_SDCCH8_SACCH8C_CBCH) {</span><br><span style="color: hsl(120, 100%, 40%);">+                           lchan = &trx->ts[i].lchan[2];</span><br><span style="color: hsl(120, 100%, 40%);">+                          break;</span><br><span style="color: hsl(120, 100%, 40%);">+                        }</span><br><span style="color: hsl(120, 100%, 40%);">+             }</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return lchan;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/src/common/bts_shutdown_fsm.c b/src/common/bts_shutdown_fsm.c</span><br><span>index d55b1cd..c81a4ab 100644</span><br><span>--- a/src/common/bts_shutdown_fsm.c</span><br><span>+++ b/src/common/bts_shutdown_fsm.c</span><br><span>@@ -28,6 +28,7 @@</span><br><span> #include <osmo-bts/logging.h></span><br><span> #include <osmo-bts/gsm_data.h></span><br><span> #include <osmo-bts/bts_model.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmo-bts/bts.h></span><br><span> </span><br><span> #define X(s) (1 << (s))</span><br><span> </span><br><span>diff --git a/src/common/gsm_data.c b/src/common/gsm_data.c</span><br><span>index 57f33ae..c63793c 100644</span><br><span>--- a/src/common/gsm_data.c</span><br><span>+++ b/src/common/gsm_data.c</span><br><span>@@ -30,74 +30,13 @@</span><br><span> #include <osmocom/core/talloc.h></span><br><span> #include <osmocom/core/statistics.h></span><br><span> #include <osmocom/core/fsm.h></span><br><span style="color: hsl(0, 100%, 40%);">-#include <osmocom/core/tdef.h></span><br><span> </span><br><span> #include <osmocom/gsm/gsm_utils.h></span><br><span> #include <osmocom/gsm/abis_nm.h></span><br><span> #include <osmocom/codec/ecu.h></span><br><span> </span><br><span> #include <osmo-bts/gsm_data.h></span><br><span style="color: hsl(0, 100%, 40%);">-#include <osmo-bts/bts_shutdown_fsm.h></span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static struct osmo_tdef bts_T_defs[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-     /* T-1: FIXME: Ideally should be dynamically calculated per trx at</span><br><span style="color: hsl(0, 100%, 40%);">-       * shutdown start based on params below, and highest trx value taken:</span><br><span style="color: hsl(0, 100%, 40%);">-    * + VTY's power-ramp step-interval.</span><br><span style="color: hsl(0, 100%, 40%);">-         * + Amount of steps needed (taking into account how many dB each step moves).</span><br><span style="color: hsl(0, 100%, 40%);">-   * + Extra time to get response back for each step.</span><br><span style="color: hsl(0, 100%, 40%);">-      * For now we simply give 5 mins, which should be enough for any</span><br><span style="color: hsl(0, 100%, 40%);">-         * acceptable setup, while still ensuring will timeout at some point if</span><br><span style="color: hsl(0, 100%, 40%);">-  * something fails in the ramp down procedure.</span><br><span style="color: hsl(0, 100%, 40%);">-   */</span><br><span style="color: hsl(0, 100%, 40%);">-     { .T=-1, .default_val=300, .desc="Time after which osmo-bts exits if regular ramp down during shut down process does not finish (s)" },</span><br><span style="color: hsl(0, 100%, 40%);">-       { .T=-2, .default_val=3, .desc="Time after which osmo-bts exits if requesting transceivers to stop during shut down process does not finish (s)" },</span><br><span style="color: hsl(0, 100%, 40%);">-   {}</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-const struct value_string bts_attribute_names[] = {</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_VALUE_STRING(BTS_TYPE_VARIANT),</span><br><span style="color: hsl(0, 100%, 40%);">-    OSMO_VALUE_STRING(BTS_SUB_MODEL),</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_VALUE_STRING(TRX_PHY_VERSION),</span><br><span style="color: hsl(0, 100%, 40%);">-     { 0, NULL }</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-enum bts_attribute str2btsattr(const char *s)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-     return get_string_value(bts_attribute_names, s);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-const char *btsatttr2str(enum bts_attribute v)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-        return get_value_string(bts_attribute_names, v);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-const struct value_string osmo_bts_variant_names[_NUM_BTS_VARIANT + 1] = {</span><br><span style="color: hsl(0, 100%, 40%);">-     { BTS_UNKNOWN,          "unknown" },</span><br><span style="color: hsl(0, 100%, 40%);">-  { BTS_OSMO_LITECELL15,  "osmo-bts-lc15" },</span><br><span style="color: hsl(0, 100%, 40%);">-    { BTS_OSMO_OC2G,        "osmo-bts-oc2g" },</span><br><span style="color: hsl(0, 100%, 40%);">-    { BTS_OSMO_OCTPHY,      "osmo-bts-octphy" },</span><br><span style="color: hsl(0, 100%, 40%);">-  { BTS_OSMO_SYSMO,       "osmo-bts-sysmo" },</span><br><span style="color: hsl(0, 100%, 40%);">-   { BTS_OSMO_TRX,         "osmo-bts-trx" },</span><br><span style="color: hsl(0, 100%, 40%);">-     { BTS_OSMO_VIRTUAL,     "osmo-bts-virtual" },</span><br><span style="color: hsl(0, 100%, 40%);">- { BTS_OSMO_OMLDUMMY,    "osmo-bts-omldummy" },</span><br><span style="color: hsl(0, 100%, 40%);">-        { 0, NULL }</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-enum gsm_bts_type_variant str2btsvariant(const char *arg)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- return get_string_value(osmo_bts_variant_names, arg);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-const char *btsvariant2str(enum gsm_bts_type_variant v)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-  return get_value_string(osmo_bts_variant_names, v);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-const struct value_string bts_impl_flag_desc[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-  { BTS_INTERNAL_FLAG_MS_PWR_CTRL_DSP,    "DSP/HW based MS Power Control Loop" },</span><br><span style="color: hsl(0, 100%, 40%);">-       { BTS_INTERNAL_FLAG_MEAS_PAYLOAD_COMB,  "Measurement and Payload data combined" },</span><br><span style="color: hsl(0, 100%, 40%);">-    { 0, NULL }</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmo-bts/bts.h></span><br><span> </span><br><span> const struct value_string gsm_pchant_names[13] = {</span><br><span>     { GSM_PCHAN_NONE,       "NONE" },</span><br><span>@@ -164,21 +103,6 @@</span><br><span>   return get_value_string(lchan_s_names, s);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-       struct gsm_bts *bts;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    if (num >= net->num_bts)</span><br><span style="color: hsl(0, 100%, 40%);">-          return NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    llist_for_each_entry(bts, &net->bts_list, list) {</span><br><span style="color: hsl(0, 100%, 40%);">-                if (bts->nr == num)</span><br><span style="color: hsl(0, 100%, 40%);">-                  return bts;</span><br><span style="color: hsl(0, 100%, 40%);">-     }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       return NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts)</span><br><span> {</span><br><span>     struct gsm_bts_trx *trx = talloc_zero(bts, struct gsm_bts_trx);</span><br><span>@@ -233,88 +157,6 @@</span><br><span>       return trx;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static const uint8_t bts_nse_timer_default[] = { 3, 3, 3, 3, 30, 3, 10 };</span><br><span style="color: hsl(0, 100%, 40%);">-static const uint8_t bts_cell_timer_default[] =</span><br><span style="color: hsl(0, 100%, 40%);">-                            { 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 };</span><br><span style="color: hsl(0, 100%, 40%);">-static const struct gprs_rlc_cfg rlc_cfg_default = {</span><br><span style="color: hsl(0, 100%, 40%);">-     .parameter = {</span><br><span style="color: hsl(0, 100%, 40%);">-          [RLC_T3142] = 20,</span><br><span style="color: hsl(0, 100%, 40%);">-               [RLC_T3169] = 5,</span><br><span style="color: hsl(0, 100%, 40%);">-                [RLC_T3191] = 5,</span><br><span style="color: hsl(0, 100%, 40%);">-                [RLC_T3193] = 160, /* 10ms */</span><br><span style="color: hsl(0, 100%, 40%);">-           [RLC_T3195] = 5,</span><br><span style="color: hsl(0, 100%, 40%);">-                [RLC_N3101] = 10,</span><br><span style="color: hsl(0, 100%, 40%);">-               [RLC_N3103] = 4,</span><br><span style="color: hsl(0, 100%, 40%);">-                [RLC_N3105] = 8,</span><br><span style="color: hsl(0, 100%, 40%);">-                [CV_COUNTDOWN] = 15,</span><br><span style="color: hsl(0, 100%, 40%);">-            [T_DL_TBF_EXT] = 250 * 10, /* ms */</span><br><span style="color: hsl(0, 100%, 40%);">-             [T_UL_TBF_EXT] = 250 * 10, /* ms */</span><br><span style="color: hsl(0, 100%, 40%);">-     },</span><br><span style="color: hsl(0, 100%, 40%);">-      .paging = {</span><br><span style="color: hsl(0, 100%, 40%);">-             .repeat_time = 5 * 50, /* ms */</span><br><span style="color: hsl(0, 100%, 40%);">-         .repeat_count = 3,</span><br><span style="color: hsl(0, 100%, 40%);">-      },</span><br><span style="color: hsl(0, 100%, 40%);">-      .cs_mask = 0x1fff,</span><br><span style="color: hsl(0, 100%, 40%);">-      .initial_cs = 2,</span><br><span style="color: hsl(0, 100%, 40%);">-        .initial_mcs = 6,</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-struct gsm_bts *gsm_bts_alloc(void *ctx, uint8_t bts_num)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-   struct gsm_bts *bts = talloc_zero(ctx, struct gsm_bts);</span><br><span style="color: hsl(0, 100%, 40%);">- int i;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  if (!bts)</span><br><span style="color: hsl(0, 100%, 40%);">-               return NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    bts->nr = bts_num;</span><br><span style="color: hsl(0, 100%, 40%);">-   bts->num_trx = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-    INIT_LLIST_HEAD(&bts->trx_list);</span><br><span style="color: hsl(0, 100%, 40%);">- bts->ms_max_power = 15;      /* dBm */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       bts->T_defs = bts_T_defs;</span><br><span style="color: hsl(0, 100%, 40%);">-    osmo_tdefs_reset(bts->T_defs);</span><br><span style="color: hsl(0, 100%, 40%);">-       bts->shutdown_fi = osmo_fsm_inst_alloc(&bts_shutdown_fsm, bts, bts,</span><br><span style="color: hsl(0, 100%, 40%);">-                                             LOGL_INFO, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-        osmo_fsm_inst_update_id_f(bts->shutdown_fi, "bts%d", bts->nr);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  gsm_mo_init(&bts->mo, bts, NM_OC_BTS,</span><br><span style="color: hsl(0, 100%, 40%);">-                    bts->nr, 0xff, 0xff);</span><br><span style="color: hsl(0, 100%, 40%);">-        gsm_mo_init(&bts->site_mgr.mo, bts, NM_OC_SITE_MANAGER,</span><br><span style="color: hsl(0, 100%, 40%);">-                  0xff, 0xff, 0xff);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {</span><br><span style="color: hsl(0, 100%, 40%);">-                bts->gprs.nsvc[i].bts = bts;</span><br><span style="color: hsl(0, 100%, 40%);">-         bts->gprs.nsvc[i].id = i;</span><br><span style="color: hsl(0, 100%, 40%);">-            gsm_mo_init(&bts->gprs.nsvc[i].mo, bts, NM_OC_GPRS_NSVC,</span><br><span style="color: hsl(0, 100%, 40%);">-                         bts->nr, i, 0xff);</span><br><span style="color: hsl(0, 100%, 40%);">-   }</span><br><span style="color: hsl(0, 100%, 40%);">-       memcpy(&bts->gprs.nse.timer, bts_nse_timer_default,</span><br><span style="color: hsl(0, 100%, 40%);">-              sizeof(bts->gprs.nse.timer));</span><br><span style="color: hsl(0, 100%, 40%);">-        gsm_mo_init(&bts->gprs.nse.mo, bts, NM_OC_GPRS_NSE,</span><br><span style="color: hsl(0, 100%, 40%);">-                      bts->nr, 0xff, 0xff);</span><br><span style="color: hsl(0, 100%, 40%);">-        memcpy(&bts->gprs.cell.timer, bts_cell_timer_default,</span><br><span style="color: hsl(0, 100%, 40%);">-            sizeof(bts->gprs.cell.timer));</span><br><span style="color: hsl(0, 100%, 40%);">-       gsm_mo_init(&bts->gprs.cell.mo, bts, NM_OC_GPRS_CELL,</span><br><span style="color: hsl(0, 100%, 40%);">-                    bts->nr, 0xff, 0xff);</span><br><span style="color: hsl(0, 100%, 40%);">-        memcpy(&bts->gprs.cell.rlc_cfg, &rlc_cfg_default,</span><br><span style="color: hsl(0, 100%, 40%);">-            sizeof(bts->gprs.cell.rlc_cfg));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     /* create our primary TRX. It will be initialized during bts_init() */</span><br><span style="color: hsl(0, 100%, 40%);">-  bts->c0 = gsm_bts_trx_alloc(bts);</span><br><span style="color: hsl(0, 100%, 40%);">-    if (!bts->c0) {</span><br><span style="color: hsl(0, 100%, 40%);">-              talloc_free(bts);</span><br><span style="color: hsl(0, 100%, 40%);">-               return NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-    }</span><br><span style="color: hsl(0, 100%, 40%);">-       bts->c0->ts[0].pchan = GSM_PCHAN_CCCH_SDCCH4;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     bts->features = bitvec_alloc(MAX_BTS_FEATURES / 8, bts);</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(bts->features != NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  return bts;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num)</span><br><span> {</span><br><span>         struct gsm_bts_trx *trx;</span><br><span>@@ -499,25 +341,12 @@</span><br><span>     return gsm_pchan2chan_nr(as_pchan, lchan->ts->nr, lchan->nr);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* return the gsm_lchan for the CBCH (if it exists at all) */</span><br><span style="color: hsl(0, 100%, 40%);">-struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts)</span><br><span style="color: hsl(120, 100%, 40%);">+uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-   struct gsm_lchan *lchan = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- struct gsm_bts_trx *trx = bts->c0;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   if (trx->ts[0].pchan == GSM_PCHAN_CCCH_SDCCH4_CBCH)</span><br><span style="color: hsl(0, 100%, 40%);">-          lchan = &trx->ts[0].lchan[2];</span><br><span style="color: hsl(0, 100%, 40%);">-    else {</span><br><span style="color: hsl(0, 100%, 40%);">-          int i;</span><br><span style="color: hsl(0, 100%, 40%);">-          for (i = 0; i < 8; i++) {</span><br><span style="color: hsl(0, 100%, 40%);">-                    if (trx->ts[i].pchan == GSM_PCHAN_SDCCH8_SACCH8C_CBCH) {</span><br><span style="color: hsl(0, 100%, 40%);">-                             lchan = &trx->ts[i].lchan[2];</span><br><span style="color: hsl(0, 100%, 40%);">-                            break;</span><br><span style="color: hsl(0, 100%, 40%);">-                  }</span><br><span style="color: hsl(0, 100%, 40%);">-               }</span><br><span style="color: hsl(0, 100%, 40%);">-       }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       return lchan;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ts->tsc != -1)</span><br><span style="color: hsl(120, 100%, 40%);">+         return ts->tsc;</span><br><span style="color: hsl(120, 100%, 40%);">+    else</span><br><span style="color: hsl(120, 100%, 40%);">+          return ts->trx->bts->bsic & 7;</span><br><span> }</span><br><span> </span><br><span> /* determine logical channel based on TRX and channel number IE */</span><br><span>diff --git a/src/common/load_indication.c b/src/common/load_indication.c</span><br><span>index 8d9b56f..c9b2645 100644</span><br><span>--- a/src/common/load_indication.c</span><br><span>+++ b/src/common/load_indication.c</span><br><span>@@ -27,6 +27,7 @@</span><br><span> #include <osmo-bts/gsm_data.h></span><br><span> #include <osmo-bts/rsl.h></span><br><span> #include <osmo-bts/paging.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmo-bts/bts.h></span><br><span> </span><br><span> static void reset_load_counters(struct gsm_bts *bts)</span><br><span> {</span><br><span>diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c</span><br><span>index 52b0566..1817849 100644</span><br><span>--- a/src/common/msg_utils.c</span><br><span>+++ b/src/common/msg_utils.c</span><br><span>@@ -23,6 +23,7 @@</span><br><span> #include <osmo-bts/oml.h></span><br><span> #include <osmo-bts/amr.h></span><br><span> #include <osmo-bts/rsl.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmo-bts/bts.h></span><br><span> </span><br><span> #include <osmocom/gsm/protocol/ipaccess.h></span><br><span> #include <osmocom/gsm/protocol/gsm_12_21.h></span><br><span>diff --git a/src/common/scheduler.c b/src/common/scheduler.c</span><br><span>index 3068918..7375a1a 100644</span><br><span>--- a/src/common/scheduler.c</span><br><span>+++ b/src/common/scheduler.c</span><br><span>@@ -42,6 +42,7 @@</span><br><span> #include <osmo-bts/l1sap.h></span><br><span> #include <osmo-bts/scheduler.h></span><br><span> #include <osmo-bts/scheduler_backend.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmo-bts/bts.h></span><br><span> </span><br><span> extern void *tall_bts_ctx;</span><br><span> </span><br><span>diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c</span><br><span>index f5bc3c8..4a86c4e 100644</span><br><span>--- a/src/common/sysinfo.c</span><br><span>+++ b/src/common/sysinfo.c</span><br><span>@@ -25,6 +25,7 @@</span><br><span> #include <osmo-bts/logging.h></span><br><span> #include <osmo-bts/gsm_data.h></span><br><span> #include <osmo-bts/pcu_if.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmo-bts/bts.h></span><br><span> </span><br><span> /* properly increment SI2q index and return SI2q data for scheduling */</span><br><span> static inline uint8_t *get_si2q_inc_index(struct gsm_bts *bts)</span><br><span>diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c</span><br><span>index 0adc8fe..c03b411 100644</span><br><span>--- a/src/osmo-bts-octphy/l1_if.c</span><br><span>+++ b/src/osmo-bts-octphy/l1_if.c</span><br><span>@@ -43,6 +43,7 @@</span><br><span> #include <osmo-bts/logging.h></span><br><span> #include <osmo-bts/l1sap.h></span><br><span> #include <osmo-bts/handover.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmo-bts/bts.h></span><br><span> </span><br><span> #include "l1_if.h"</span><br><span> #include "l1_oml.h"</span><br><span>diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c</span><br><span>index 0653f01..7876612 100644</span><br><span>--- a/src/osmo-bts-sysmo/sysmobts_vty.c</span><br><span>+++ b/src/osmo-bts-sysmo/sysmobts_vty.c</span><br><span>@@ -45,6 +45,7 @@</span><br><span> #include <osmo-bts/bts_model.h></span><br><span> #include <osmo-bts/vty.h></span><br><span> #include <osmo-bts/rsl.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmo-bts/bts.h></span><br><span> </span><br><span> #include "femtobts.h"</span><br><span> #include "l1_if.h"</span><br><span>diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c</span><br><span>index 2e52958..fb75a4e 100644</span><br><span>--- a/src/osmo-bts-trx/trx_vty.c</span><br><span>+++ b/src/osmo-bts-trx/trx_vty.c</span><br><span>@@ -42,6 +42,7 @@</span><br><span> #include <osmo-bts/logging.h></span><br><span> #include <osmo-bts/vty.h></span><br><span> #include <osmo-bts/scheduler.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmo-bts/bts.h></span><br><span> </span><br><span> #include "l1_if.h"</span><br><span> #include "trx_if.h"</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bts/+/19123">change 19123</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-bts/+/19123"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bts </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I0a4219e3f64f625ee8b364bf408b8d2bcc8085c5 </div>
<div style="display:none"> Gerrit-Change-Number: 19123 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Hoernchen <ewild@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>