Restructure SI2quater generation
In preparation for extended SI2q messages:
* add SI2q-specific accessor macro
* add *_offset variables to gsm_bts struct
* internalize memory check while generating rest octets - introduce
budget concept (number of bits available in a given message)
* internalize *arfcn_size() functions as they are not needed outside of
si2q_num() anymore
* change rest octets generation to work with gsm_bts struct directly
* do not generate rest octets if no SI2q is necessary
* adjust unit tests accordingly (cosmetic changes only to avoid
regressions)
Requires: I92e12e91605bdab9916a3f665705287572434f74 in libosmocore
Change-Id: Ib554cf7ffc949a321571e1ae2ada1160e1b35fa6
Related: RT#8792
diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index edc550e..0e5bc91 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -25,6 +25,7 @@
#endif
#include <openbsc/common_cs.h>
+#include <openbsc/rest_octets.h>
struct osmo_bsc_data;
@@ -485,6 +486,7 @@
struct gsm_bts_trx_ts ts[TRX_NR_TS];
};
+#define GSM_BTS_SI2Q(bts) (struct gsm48_system_information_type_2quater *)((bts)->si_buf[SYSINFO_TYPE_2quater])
#define GSM_BTS_SI(bts, i) (void *)((bts)->si_buf[i])
#define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i])
@@ -717,10 +719,13 @@
/* bitmask of all SI that are present/valid in si_buf */
uint32_t si_valid;
/* 3GPP TS 44.018 Table 10.5.2.33b.1 INDEX and COUNT for SI2quater */
- uint8_t si2q_index;
- uint8_t si2q_count;
+ uint8_t si2q_index; /* distinguish individual SI2quater messages */
+ uint8_t si2q_count; /* si2q_index for the last (highest indexed) individual SI2quater message */
/* buffers where we put the pre-computed SI */
sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE];
+ /* offsets used while generating SI2quater */
+ size_t e_offset;
+ size_t u_offset;
/* ip.accesss Unit ID's have Site/BTS/TRX layout */
union {
diff --git a/openbsc/include/openbsc/rest_octets.h b/openbsc/include/openbsc/rest_octets.h
index 73ce57b..7b324d3 100644
--- a/openbsc/include/openbsc/rest_octets.h
+++ b/openbsc/include/openbsc/rest_octets.h
@@ -13,8 +13,7 @@
/* generate SI1 rest octets */
int rest_octets_si1(uint8_t *data, uint8_t *nch_pos, int is1800_net);
-int rest_octets_si2quater(uint8_t *data, uint8_t index, uint8_t count, const struct osmo_earfcn_si2q *e,
- const uint16_t *u, const uint16_t *sc, size_t u_len);
+int rest_octets_si2quater(uint8_t *data, struct gsm_bts *bts);
int rest_octets_si6(uint8_t *data, bool is1800_net);
struct gsm48_si_selection_params {
diff --git a/openbsc/include/openbsc/system_information.h b/openbsc/include/openbsc/system_information.h
index b012107..21016b8 100644
--- a/openbsc/include/openbsc/system_information.h
+++ b/openbsc/include/openbsc/system_information.h
@@ -8,13 +8,12 @@
struct gsm_bts;
int gsm_generate_si(struct gsm_bts *bts, enum osmo_sysinfo_type type);
-unsigned uarfcn_size(const uint16_t *u, const uint16_t *sc, size_t u_len);
-unsigned earfcn_size(const struct osmo_earfcn_si2q *e);
+size_t si2q_earfcn_count(const struct osmo_earfcn_si2q *e);
unsigned range1024_p(unsigned n);
unsigned range512_q(unsigned m);
int range_encode(enum gsm48_range r, int *arfcns, int arfcns_used, int *w,
int f0, uint8_t *chan_list);
-uint8_t si2q_num(const struct gsm_bts *bts);
+uint8_t si2q_num(struct gsm_bts *bts);
int bts_uarfcn_del(struct gsm_bts *bts, uint16_t arfcn, uint16_t scramble);
int bts_uarfcn_add(struct gsm_bts *bts, uint16_t arfcn, uint16_t scramble,
bool diversity);