[MERGED] libosmocore[master]: egprs: Add CPS tables from TS 04.60

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Tom Tsou gerrit-no-reply at lists.osmocom.org
Mon Jul 25 18:33:26 UTC 2016


Tom Tsou has submitted this change and it was merged.

Change subject: egprs: Add CPS tables from TS 04.60
......................................................................


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
---
M include/Makefile.am
A include/osmocom/gprs/gprs_rlc.h
M src/gsm/Makefile.am
A src/gsm/gprs_rlc.c
M src/gsm/libosmogsm.map
5 files changed, 137 insertions(+), 1 deletion(-)

Approvals:
  Max: Looks good to me, but someone else must approve
  Jenkins Builder: Verified
  Holger Freyther: Looks good to me, approved



diff --git a/include/Makefile.am b/include/Makefile.am
index e420a64..c125691 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -51,6 +51,7 @@
                        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 0000000..d34d49b
--- /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 0f43f48..a2f2524 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -15,7 +15,7 @@
 
 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 0000000..d6ccbbe
--- /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 9667ea0..f530b6f 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -48,6 +48,8 @@
 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;

-- 
To view, visit https://gerrit.osmocom.org/548
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I09fe6514a0e2e51bb3206f8387633f7e0255345f
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Tom Tsou <tom at tsou.cc>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Tom Tsou <tom at tsou.cc>



More information about the gerrit-log mailing list