Move libosmogsm TS 44.060 declarations under include/osmocom/gsm/

Currently there's a big mess where include dir osmocom/gprs/ is used by
both libosmogsm and libosmogb.
Most of the header files under osmocom/gprs/ are actually all the
headers of libosmogb (there's no osmocom/gb/ dir). But a couple files
are actually RLC/MAC (TS 44.060) related are are also stored in there.
Those files have no relation/use in Gb, and are actually interused with
GSM (eg System Information 13 Rest Octets).
Hence, it makes sense to have the RLC/MAC related parts inside
osmocom/gsm/ as they should be in libosmogsm (and they actually are,
see gprs_rlc.h function implemented in src/gsm/gsm48_rest_octets.c).

The fact that some libosmogsm headers were placed in osmocom/gprs
instead of osmocom/gsm already created some issues, like
libosmocore.spec.in putting "%_includedir/%name/osmocom/gprs/" under
libosmogb, which is wrong.

As a first step to fix the mess, we move the 2 RLC/MAC headers currently
under osmocom/gprs/{gprs_rlc,protocol/gsm_04_60}.h under a single header
gsm/protocol/gsm_44_060.h
The two old headers are left existing for backward compatibility and now
simply include the new libosmogsm header, plus a warning asking users to
switch to the new header so we can eventually get rid of them.
This means libosmogb depends on libosmogsm, which is fine and was
already the case beforehand (libosmogb using functions like
gsm48_encode_ra() and linking against it in src/gb/Makefile.am).

Change-Id: I70cc21bf25a7081070738abacb409ed19094c3b2
This commit is contained in:
Pau Espin 2023-02-17 12:30:57 +01:00
parent ce4a86525c
commit 0158b05337
8 changed files with 261 additions and 258 deletions

View File

@ -7,3 +7,4 @@
# If any interfaces have been added since the last public release: c:r:a + 1.
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
libosmogsm new header osmocom/gsm/protocol/gsm_44_060.h

View File

@ -1,54 +1,4 @@
/*! \file gprs_rlc.h */
#pragma once
#include <stdint.h>
/*! Structure for CPS coding and puncturing scheme (TS 04.60 10.4.8a) */
struct egprs_cps {
uint8_t bits;
uint8_t mcs;
uint8_t p[2];
};
/*! CPS puncturing table selection (TS 04.60 10.4.8a) */
enum egprs_cps_punc {
EGPRS_CPS_P1,
EGPRS_CPS_P2,
EGPRS_CPS_P3,
EGPRS_CPS_NONE = -1,
};
/*! EGPRS header types (TS 04.60 10.0a.2) */
enum egprs_hdr_type {
EGPRS_HDR_TYPE1,
EGPRS_HDR_TYPE2,
EGPRS_HDR_TYPE3,
};
enum osmo_gprs_cs {
OSMO_GPRS_CS_NONE,
OSMO_GPRS_CS1,
OSMO_GPRS_CS2,
OSMO_GPRS_CS3,
OSMO_GPRS_CS4,
OSMO_GPRS_MCS1,
OSMO_GPRS_MCS2,
OSMO_GPRS_MCS3,
OSMO_GPRS_MCS4,
OSMO_GPRS_MCS5,
OSMO_GPRS_MCS6,
OSMO_GPRS_MCS7,
OSMO_GPRS_MCS8,
OSMO_GPRS_MCS9,
_NUM_OSMO_GPRS_CS
};
int egprs_get_cps(struct egprs_cps *cps, uint8_t type, uint8_t bits);
int osmo_gprs_ul_block_size_bits(enum osmo_gprs_cs cs);
int osmo_gprs_dl_block_size_bits(enum osmo_gprs_cs cs);
int osmo_gprs_ul_block_size_bytes(enum osmo_gprs_cs cs);
int osmo_gprs_dl_block_size_bytes(enum osmo_gprs_cs cs);
enum osmo_gprs_cs osmo_gprs_ul_cs_by_block_bytes(uint8_t block_size);
enum osmo_gprs_cs osmo_gprs_dl_cs_by_block_bytes(uint8_t block_size);
#pragma message "Header osmocom/gprs/gprs_rlc.h is deprecated, include osmocom/gsm/protocol/gsm_44_060.h instead"
#include <osmocom/gsm/protocol/gsm_44_060.h>

View File

@ -1,202 +1,4 @@
/*! \file gsm_04_60.h
* General Packet Radio Service (GPRS).
* Radio Link Control / Medium Access Control (RLC/MAC) protocol
* 3GPP TS 04.60 version 8.27.0 Release 1999
*/
#pragma once
#include <stdint.h>
#include <osmocom/core/endian.h>
/* TS 04.60 10.3a.4.1.1 */
struct gprs_rlc_ul_header_egprs_1 {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t r:1,
si:1,
cv:4,
tfi_hi:2;
uint8_t tfi_lo:3,
bsn1_hi:5;
uint8_t bsn1_lo:6,
bsn2_hi:2;
uint8_t bsn2_lo:8;
uint8_t cps:5,
rsb:1,
pi:1,
spare_hi:1;
uint8_t spare_lo:6,
dummy:2;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
uint8_t tfi_hi:2, cv:4, si:1, r:1;
uint8_t bsn1_hi:5, tfi_lo:3;
uint8_t bsn2_hi:2, bsn1_lo:6;
uint8_t bsn2_lo:8;
uint8_t spare_hi:1, pi:1, rsb:1, cps:5;
uint8_t dummy:2, spare_lo:6;
#endif
} __attribute__ ((packed));
/* TS 04.60 10.3a.4.2.1 */
struct gprs_rlc_ul_header_egprs_2 {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t r:1,
si:1,
cv:4,
tfi_hi:2;
uint8_t tfi_lo:3,
bsn1_hi:5;
uint8_t bsn1_lo:6,
cps_hi:2;
uint8_t cps_lo:1,
rsb:1,
pi:1,
spare_hi:5;
uint8_t spare_lo:5,
dummy:3;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
uint8_t tfi_hi:2, cv:4, si:1, r:1;
uint8_t bsn1_hi:5, tfi_lo:3;
uint8_t cps_hi:2, bsn1_lo:6;
uint8_t spare_hi:5, pi:1, rsb:1, cps_lo:1;
uint8_t dummy:3, spare_lo:5;
#endif
} __attribute__ ((packed));
/* TS 04.60 10.3a.4.3.1 */
struct gprs_rlc_ul_header_egprs_3 {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t r:1,
si:1,
cv:4,
tfi_hi:2;
uint8_t tfi_lo:3,
bsn1_hi:5;
uint8_t bsn1_lo:6,
cps_hi:2;
uint8_t cps_lo:2,
spb:2,
rsb:1,
pi:1,
spare:1,
dummy:1;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
uint8_t tfi_hi:2, cv:4, si:1, r:1;
uint8_t bsn1_hi:5, tfi_lo:3;
uint8_t cps_hi:2, bsn1_lo:6;
uint8_t dummy:1, spare:1, pi:1, rsb:1, spb:2, cps_lo:2;
#endif
} __attribute__ ((packed));
struct gprs_rlc_dl_header_egprs_1 {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t usf:3,
es_p:2,
rrbp:2,
tfi_hi:1;
uint8_t tfi_lo:4,
pr:2,
bsn1_hi:2;
uint8_t bsn1_mid:8;
uint8_t bsn1_lo:1,
bsn2_hi:7;
uint8_t bsn2_lo:3,
cps:5;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3;
uint8_t bsn1_hi:2, pr:2, tfi_lo:4;
uint8_t bsn1_mid:8;
uint8_t bsn2_hi:7, bsn1_lo:1;
uint8_t cps:5, bsn2_lo:3;
#endif
} __attribute__ ((packed));
struct gprs_rlc_dl_header_egprs_2 {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t usf:3,
es_p:2,
rrbp:2,
tfi_hi:1;
uint8_t tfi_lo:4,
pr:2,
bsn1_hi:2;
uint8_t bsn1_mid:8;
uint8_t bsn1_lo:1,
cps:3,
dummy:4;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3;
uint8_t bsn1_hi:2, pr:2, tfi_lo:4;
uint8_t bsn1_mid:8;
uint8_t dummy:4, cps:3, bsn1_lo:1;
#endif
} __attribute__ ((packed));
struct gprs_rlc_dl_header_egprs_3 {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t usf:3,
es_p:2,
rrbp:2,
tfi_hi:1;
uint8_t tfi_lo:4,
pr:2,
bsn1_hi:2;
uint8_t bsn1_mid:8;
uint8_t bsn1_lo:1,
cps:4,
spb:2,
dummy:1;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3;
uint8_t bsn1_hi:2, pr:2, tfi_lo:4;
uint8_t bsn1_mid:8;
uint8_t dummy:1, spb:2, cps:4, bsn1_lo:1;
#endif
} __attribute__ ((packed));
/* TS 44.060 Table 12.24.2
* Meaning of values documented in TS 23.060 Chapter 6.3.3.1: Network Mode of Operation */
enum osmo_gprs_nmo {
GPRS_NMO_I = 0, /* CS pagin on GPRS paging or traffic channel */
GPRS_NMO_II = 1, /* all paging on CCCH */
GPRS_NMO_III = 2, /* no paging coordination */
};
/* TS 44.060 12.24 */
struct osmo_gprs_cell_options {
enum osmo_gprs_nmo nmo;
/* T3168: wait for packet uplink assignment message */
uint32_t t3168; /* in milliseconds */
/* T3192: wait for release of the TBF after reception of the final block */
uint32_t t3192; /* in milliseconds */
uint32_t drx_timer_max;/* in seconds */
uint32_t bs_cv_max;
uint8_t supports_egprs_11bit_rach;
bool ctrl_ack_type_use_block; /* use PACKET CONTROL ACKNOWLEDGMENT */
uint8_t ext_info_present;
struct {
uint8_t egprs_supported;
uint8_t use_egprs_p_ch_req;
uint8_t bep_period;
uint8_t pfc_supported;
uint8_t dtm_supported;
uint8_t bss_paging_coordination;
bool ccn_active;
} ext_info;
};
/* TS 04.60 Table 12.9.2 */
struct osmo_gprs_power_ctrl_pars {
uint8_t alpha;
uint8_t t_avg_w;
uint8_t t_avg_t;
uint8_t pc_meas_chan;
uint8_t n_avg_i;
};
#pragma message "Header osmocom/gprs/protocol/gsm_04_60.h is deprecated, include osmocom/gsm/protocol/gsm_44_060.h instead"
#include <osmocom/gsm/protocol/gsm_44_060.h>

View File

@ -2,7 +2,7 @@
#include <stdbool.h>
#include <osmocom/gsm/sysinfo.h>
#include <osmocom/gprs/protocol/gsm_04_60.h>
#include <osmocom/gsm/protocol/gsm_44_060.h>
/* 16 is the max. number of SI2quater messages according to 3GPP TS 44.018 Table 10.5.2.33b.1:
4-bit index is used (2#1111 = 10#15) */

View File

@ -17,6 +17,7 @@ osmogsmproto_HEADERS = \
gsm_25_415.h \
gsm_29_118.h \
gsm_44_004.h \
gsm_44_060.h \
gsm_44_318.h \
gsm_48_049.h \
gsm_48_071.h \

View File

@ -0,0 +1,252 @@
/*! \file gsm_44_060.h
* General Packet Radio Service (GPRS).
* Radio Link Control / Medium Access Control (RLC/MAC) protocol
* 3GPP TS 44.060
*/
#pragma once
#include <stdint.h>
#include <osmocom/core/endian.h>
/* TS 44.060 10.3a.4.1.1 */
struct gprs_rlc_ul_header_egprs_1 {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t r:1,
si:1,
cv:4,
tfi_hi:2;
uint8_t tfi_lo:3,
bsn1_hi:5;
uint8_t bsn1_lo:6,
bsn2_hi:2;
uint8_t bsn2_lo:8;
uint8_t cps:5,
rsb:1,
pi:1,
spare_hi:1;
uint8_t spare_lo:6,
dummy:2;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
uint8_t tfi_hi:2, cv:4, si:1, r:1;
uint8_t bsn1_hi:5, tfi_lo:3;
uint8_t bsn2_hi:2, bsn1_lo:6;
uint8_t bsn2_lo:8;
uint8_t spare_hi:1, pi:1, rsb:1, cps:5;
uint8_t dummy:2, spare_lo:6;
#endif
} __attribute__ ((packed));
/* TS 44.060 10.3a.4.2.1 */
struct gprs_rlc_ul_header_egprs_2 {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t r:1,
si:1,
cv:4,
tfi_hi:2;
uint8_t tfi_lo:3,
bsn1_hi:5;
uint8_t bsn1_lo:6,
cps_hi:2;
uint8_t cps_lo:1,
rsb:1,
pi:1,
spare_hi:5;
uint8_t spare_lo:5,
dummy:3;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
uint8_t tfi_hi:2, cv:4, si:1, r:1;
uint8_t bsn1_hi:5, tfi_lo:3;
uint8_t cps_hi:2, bsn1_lo:6;
uint8_t spare_hi:5, pi:1, rsb:1, cps_lo:1;
uint8_t dummy:3, spare_lo:5;
#endif
} __attribute__ ((packed));
/* TS 44.060 10.3a.4.3.1 */
struct gprs_rlc_ul_header_egprs_3 {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t r:1,
si:1,
cv:4,
tfi_hi:2;
uint8_t tfi_lo:3,
bsn1_hi:5;
uint8_t bsn1_lo:6,
cps_hi:2;
uint8_t cps_lo:2,
spb:2,
rsb:1,
pi:1,
spare:1,
dummy:1;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
uint8_t tfi_hi:2, cv:4, si:1, r:1;
uint8_t bsn1_hi:5, tfi_lo:3;
uint8_t cps_hi:2, bsn1_lo:6;
uint8_t dummy:1, spare:1, pi:1, rsb:1, spb:2, cps_lo:2;
#endif
} __attribute__ ((packed));
struct gprs_rlc_dl_header_egprs_1 {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t usf:3,
es_p:2,
rrbp:2,
tfi_hi:1;
uint8_t tfi_lo:4,
pr:2,
bsn1_hi:2;
uint8_t bsn1_mid:8;
uint8_t bsn1_lo:1,
bsn2_hi:7;
uint8_t bsn2_lo:3,
cps:5;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3;
uint8_t bsn1_hi:2, pr:2, tfi_lo:4;
uint8_t bsn1_mid:8;
uint8_t bsn2_hi:7, bsn1_lo:1;
uint8_t cps:5, bsn2_lo:3;
#endif
} __attribute__ ((packed));
struct gprs_rlc_dl_header_egprs_2 {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t usf:3,
es_p:2,
rrbp:2,
tfi_hi:1;
uint8_t tfi_lo:4,
pr:2,
bsn1_hi:2;
uint8_t bsn1_mid:8;
uint8_t bsn1_lo:1,
cps:3,
dummy:4;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3;
uint8_t bsn1_hi:2, pr:2, tfi_lo:4;
uint8_t bsn1_mid:8;
uint8_t dummy:4, cps:3, bsn1_lo:1;
#endif
} __attribute__ ((packed));
struct gprs_rlc_dl_header_egprs_3 {
#if OSMO_IS_LITTLE_ENDIAN
uint8_t usf:3,
es_p:2,
rrbp:2,
tfi_hi:1;
uint8_t tfi_lo:4,
pr:2,
bsn1_hi:2;
uint8_t bsn1_mid:8;
uint8_t bsn1_lo:1,
cps:4,
spb:2,
dummy:1;
#elif OSMO_IS_BIG_ENDIAN
/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3;
uint8_t bsn1_hi:2, pr:2, tfi_lo:4;
uint8_t bsn1_mid:8;
uint8_t dummy:1, spb:2, cps:4, bsn1_lo:1;
#endif
} __attribute__ ((packed));
/* TS 44.060 Table 12.24.2
* Meaning of values documented in TS 23.060 Chapter 6.3.3.1: Network Mode of Operation */
enum osmo_gprs_nmo {
GPRS_NMO_I = 0, /* CS pagin on GPRS paging or traffic channel */
GPRS_NMO_II = 1, /* all paging on CCCH */
GPRS_NMO_III = 2, /* no paging coordination */
};
/* TS 44.060 12.24 */
struct osmo_gprs_cell_options {
enum osmo_gprs_nmo nmo;
/* T3168: wait for packet uplink assignment message */
uint32_t t3168; /* in milliseconds */
/* T3192: wait for release of the TBF after reception of the final block */
uint32_t t3192; /* in milliseconds */
uint32_t drx_timer_max;/* in seconds */
uint32_t bs_cv_max;
uint8_t supports_egprs_11bit_rach;
bool ctrl_ack_type_use_block; /* use PACKET CONTROL ACKNOWLEDGMENT */
uint8_t ext_info_present;
struct {
uint8_t egprs_supported;
uint8_t use_egprs_p_ch_req;
uint8_t bep_period;
uint8_t pfc_supported;
uint8_t dtm_supported;
uint8_t bss_paging_coordination;
bool ccn_active;
} ext_info;
};
/* TS 44.060 Table 12.9.2 */
struct osmo_gprs_power_ctrl_pars {
uint8_t alpha;
uint8_t t_avg_w;
uint8_t t_avg_t;
uint8_t pc_meas_chan;
uint8_t n_avg_i;
};
/*! Structure for CPS coding and puncturing scheme (TS 44.060 10.4.8a) */
struct egprs_cps {
uint8_t bits;
uint8_t mcs;
uint8_t p[2];
};
/*! CPS puncturing table selection (TS 44.060 10.4.8a) */
enum egprs_cps_punc {
EGPRS_CPS_P1,
EGPRS_CPS_P2,
EGPRS_CPS_P3,
EGPRS_CPS_NONE = -1,
};
/*! EGPRS header types (TS 44.060 10.0a.2) */
enum egprs_hdr_type {
EGPRS_HDR_TYPE1,
EGPRS_HDR_TYPE2,
EGPRS_HDR_TYPE3,
};
enum osmo_gprs_cs {
OSMO_GPRS_CS_NONE,
OSMO_GPRS_CS1,
OSMO_GPRS_CS2,
OSMO_GPRS_CS3,
OSMO_GPRS_CS4,
OSMO_GPRS_MCS1,
OSMO_GPRS_MCS2,
OSMO_GPRS_MCS3,
OSMO_GPRS_MCS4,
OSMO_GPRS_MCS5,
OSMO_GPRS_MCS6,
OSMO_GPRS_MCS7,
OSMO_GPRS_MCS8,
OSMO_GPRS_MCS9,
_NUM_OSMO_GPRS_CS
};
int egprs_get_cps(struct egprs_cps *cps, uint8_t type, uint8_t bits);
int osmo_gprs_ul_block_size_bits(enum osmo_gprs_cs cs);
int osmo_gprs_dl_block_size_bits(enum osmo_gprs_cs cs);
int osmo_gprs_ul_block_size_bytes(enum osmo_gprs_cs cs);
int osmo_gprs_dl_block_size_bytes(enum osmo_gprs_cs cs);
enum osmo_gprs_cs osmo_gprs_ul_cs_by_block_bytes(uint8_t block_size);
enum osmo_gprs_cs osmo_gprs_dl_cs_by_block_bytes(uint8_t block_size);

View File

@ -31,9 +31,7 @@
#include <osmocom/core/crcgen.h>
#include <osmocom/core/endian.h>
#include <osmocom/gprs/protocol/gsm_04_60.h>
#include <osmocom/gprs/gprs_rlc.h>
#include <osmocom/gsm/protocol/gsm_44_060.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/gsm/gsm0503.h>
#include <osmocom/codec/codec.h>

View File

@ -13,9 +13,8 @@
#include <string.h>
#include <osmocom/core/utils.h>
#include <osmocom/gprs/gprs_rlc.h>
#include <osmocom/coding/gsm0503_coding.h>
#include <osmocom/gprs/protocol/gsm_04_60.h>
#include <osmocom/gsm/protocol/gsm_44_060.h>
#define EGPRS_CPS_TYPE1_TBL_SZ 29
#define EGPRS_CPS_TYPE2_TBL_SZ 8