diff options
author | Tom Tsou <tom.tsou@ettus.com> | 2016-07-14 15:13:45 -0700 |
---|---|---|
committer | Tom Tsou <tom@tsou.cc> | 2016-07-25 18:33:26 +0000 |
commit | 9a5bbf36b543ff89c0ed148428d97300880c5804 (patch) | |
tree | 3a9e3dda51e2942577140993ddc84d0665c0a751 | |
parent | 1a96946875f807b84fbb255e8b4f8f4a31b9cecc (diff) |
egprs: Add CPS tables from TS 04.60
Includes EGPRS coding and puncturing scheme (CPS) tables from 3GPP
TS 04.60. Currently osmo-bts-trx is the only user of CPS table
values, but this may change with gprsdecode and other utilities.
Change-Id: I09fe6514a0e2e51bb3206f8387633f7e0255345f
-rw-r--r-- | include/Makefile.am | 1 | ||||
-rw-r--r-- | include/osmocom/gprs/gprs_rlc.h | 27 | ||||
-rw-r--r-- | src/gsm/Makefile.am | 2 | ||||
-rw-r--r-- | src/gsm/gprs_rlc.c | 106 | ||||
-rw-r--r-- | src/gsm/libosmogsm.map | 2 |
5 files changed, 137 insertions, 1 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index e420a648..c1256916 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -51,6 +51,7 @@ nobase_include_HEADERS = \ osmocom/gprs/gprs_msgb.h \ osmocom/gprs/gprs_ns.h \ osmocom/gprs/gprs_ns_frgre.h \ + osmocom/gprs/gprs_rlc.h \ osmocom/gprs/protocol/gsm_04_60.h \ osmocom/gprs/protocol/gsm_08_16.h \ osmocom/gprs/protocol/gsm_08_18.h \ diff --git a/include/osmocom/gprs/gprs_rlc.h b/include/osmocom/gprs/gprs_rlc.h new file mode 100644 index 00000000..d34d49bf --- /dev/null +++ b/include/osmocom/gprs/gprs_rlc.h @@ -0,0 +1,27 @@ +#pragma once + +#include <stdint.h> + +/*! \brief 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]; +}; + +/*! \brief 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, +}; + +/*! \brief EGPRS header types (TS 04.60 10.0a.2) */ +enum egprs_hdr_type { + EGPRS_HDR_TYPE1, + EGPRS_HDR_TYPE2, + EGPRS_HDR_TYPE3, +}; + +int egprs_get_cps(struct egprs_cps *cps, uint8_t type, uint8_t bits); diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index 0f43f48a..a2f25244 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -15,7 +15,7 @@ lib_LTLIBRARIES = libosmogsm.la libgsmint_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \ gsm_utils.c rsl.c gsm48.c gsm48_ie.c gsm0808.c sysinfo.c \ - gprs_cipher_core.c gsm0480.c abis_nm.c gsm0502.c \ + gprs_cipher_core.c gprs_rlc.c gsm0480.c abis_nm.c gsm0502.c \ gsm0411_utils.c gsm0411_smc.c gsm0411_smr.c \ lapd_core.c lapdm.c kasumi.c gsm_04_08_gprs.c \ conv_cs2_gen.c conv_cs3_gen.c conv_xcch_gen.c \ diff --git a/src/gsm/gprs_rlc.c b/src/gsm/gprs_rlc.c new file mode 100644 index 00000000..d6ccbbe4 --- /dev/null +++ b/src/gsm/gprs_rlc.c @@ -0,0 +1,106 @@ +#include <errno.h> +#include <string.h> + +#include <osmocom/gprs/gprs_rlc.h> +#include <osmocom/gprs/protocol/gsm_04_60.h> + +#define EGPRS_CPS_TYPE1_TBL_SZ 29 +#define EGPRS_CPS_TYPE2_TBL_SZ 8 +#define EGPRS_CPS_TYPE3_TBL_SZ 16 + +/* 3GPP TS 44.060 10.4.8a.1.1 "Header type 1" */ +static const struct egprs_cps egprs_cps_table_type1[EGPRS_CPS_TYPE1_TBL_SZ] = { + { .bits = 0, .mcs = 9, .p = { EGPRS_CPS_P1, EGPRS_CPS_P1 } }, + { .bits = 1, .mcs = 9, .p = { EGPRS_CPS_P1, EGPRS_CPS_P2 } }, + { .bits = 2, .mcs = 9, .p = { EGPRS_CPS_P1, EGPRS_CPS_P3 } }, + { .bits = 3, .mcs = 0, .p = { EGPRS_CPS_NONE, EGPRS_CPS_NONE } }, + { .bits = 4, .mcs = 9, .p = { EGPRS_CPS_P2, EGPRS_CPS_P1 } }, + { .bits = 5, .mcs = 9, .p = { EGPRS_CPS_P2, EGPRS_CPS_P2 } }, + { .bits = 6, .mcs = 9, .p = { EGPRS_CPS_P2, EGPRS_CPS_P3 } }, + { .bits = 7, .mcs = 0, .p = { EGPRS_CPS_NONE, EGPRS_CPS_NONE } }, + { .bits = 8, .mcs = 9, .p = { EGPRS_CPS_P3, EGPRS_CPS_P1 } }, + { .bits = 9, .mcs = 9, .p = { EGPRS_CPS_P3, EGPRS_CPS_P2 } }, + { .bits = 10, .mcs = 9, .p = { EGPRS_CPS_P3, EGPRS_CPS_P3 } }, + { .bits = 11, .mcs = 8, .p = { EGPRS_CPS_P1, EGPRS_CPS_P1 } }, + { .bits = 12, .mcs = 8, .p = { EGPRS_CPS_P1, EGPRS_CPS_P2 } }, + { .bits = 13, .mcs = 8, .p = { EGPRS_CPS_P1, EGPRS_CPS_P3 } }, + { .bits = 14, .mcs = 8, .p = { EGPRS_CPS_P2, EGPRS_CPS_P1 } }, + { .bits = 15, .mcs = 8, .p = { EGPRS_CPS_P2, EGPRS_CPS_P2 } }, + { .bits = 16, .mcs = 8, .p = { EGPRS_CPS_P2, EGPRS_CPS_P3 } }, + { .bits = 17, .mcs = 8, .p = { EGPRS_CPS_P3, EGPRS_CPS_P1 } }, + { .bits = 18, .mcs = 8, .p = { EGPRS_CPS_P3, EGPRS_CPS_P2 } }, + { .bits = 19, .mcs = 8, .p = { EGPRS_CPS_P3, EGPRS_CPS_P3 } }, + { .bits = 20, .mcs = 7, .p = { EGPRS_CPS_P1, EGPRS_CPS_P1 } }, + { .bits = 21, .mcs = 7, .p = { EGPRS_CPS_P1, EGPRS_CPS_P2 } }, + { .bits = 22, .mcs = 7, .p = { EGPRS_CPS_P1, EGPRS_CPS_P3 } }, + { .bits = 23, .mcs = 7, .p = { EGPRS_CPS_P2, EGPRS_CPS_P1 } }, + { .bits = 24, .mcs = 7, .p = { EGPRS_CPS_P2, EGPRS_CPS_P2 } }, + { .bits = 25, .mcs = 7, .p = { EGPRS_CPS_P2, EGPRS_CPS_P3 } }, + { .bits = 26, .mcs = 7, .p = { EGPRS_CPS_P3, EGPRS_CPS_P1 } }, + { .bits = 27, .mcs = 7, .p = { EGPRS_CPS_P3, EGPRS_CPS_P2 } }, + { .bits = 28, .mcs = 7, .p = { EGPRS_CPS_P3, EGPRS_CPS_P3 } }, +}; + +/* + * 3GPP TS 44.060 10.4.8a.2.1 + * "Header type 2 in EGPRS TBF or uplink EGPRS2-A TBF" + */ +static const struct egprs_cps egprs_cps_table_type2[EGPRS_CPS_TYPE2_TBL_SZ] = { + { .bits = 0, .mcs = 6, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } }, + { .bits = 1, .mcs = 6, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } }, + { .bits = 2, .mcs = 6, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } }, + { .bits = 3, .mcs = 6, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } }, + { .bits = 4, .mcs = 5, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } }, + { .bits = 5, .mcs = 5, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } }, + { .bits = 6, .mcs = 6, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } }, + { .bits = 7, .mcs = 6, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } }, +}; + +/* 3GPP TS 44.060 10.4.8a.3 "Header type 3" */ +static const struct egprs_cps egprs_cps_table_type3[EGPRS_CPS_TYPE3_TBL_SZ] = { + { .bits = 0, .mcs = 4, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } }, + { .bits = 1, .mcs = 4, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } }, + { .bits = 2, .mcs = 4, .p = { EGPRS_CPS_P3, EGPRS_CPS_NONE } }, + { .bits = 3, .mcs = 3, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } }, + { .bits = 4, .mcs = 3, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } }, + { .bits = 5, .mcs = 3, .p = { EGPRS_CPS_P3, EGPRS_CPS_NONE } }, + { .bits = 6, .mcs = 3, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } }, + { .bits = 7, .mcs = 3, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } }, + { .bits = 8, .mcs = 3, .p = { EGPRS_CPS_P3, EGPRS_CPS_NONE } }, + { .bits = 9, .mcs = 2, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } }, + { .bits = 10, .mcs = 2, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } }, + { .bits = 11, .mcs = 1, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } }, + { .bits = 12, .mcs = 1, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } }, + { .bits = 13, .mcs = 2, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } }, + { .bits = 14, .mcs = 2, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } }, + { .bits = 15, .mcs = 0, .p = { EGPRS_CPS_NONE, EGPRS_CPS_NONE } }, +}; + +int egprs_get_cps(struct egprs_cps *cps, uint8_t type, uint8_t bits) +{ + const struct egprs_cps *table_cps; + + switch (type) { + case EGPRS_HDR_TYPE1: + if (bits >= EGPRS_CPS_TYPE1_TBL_SZ) + return -EINVAL; + table_cps = &egprs_cps_table_type1[bits]; + break; + case EGPRS_HDR_TYPE2: + if (bits >= EGPRS_CPS_TYPE2_TBL_SZ) + return -EINVAL; + table_cps = &egprs_cps_table_type2[bits]; + break; + case EGPRS_HDR_TYPE3: + if (bits >= EGPRS_CPS_TYPE3_TBL_SZ) + return -EINVAL; + table_cps = &egprs_cps_table_type3[bits]; + break; + default: + return -EINVAL; + } + + memcpy(cps, table_cps, sizeof *cps); + + return 0; +} diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 9667ea04..f530b6fa 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -48,6 +48,8 @@ gprs_tmsi2tlli; gprs_ms_net_cap_gea_supported; gprs_msgt_gmm_names; +egprs_get_cps; + gsm48_gmm_cause_names; gsm48_gsm_cause_names; gprs_att_t_strs; |