libosmocoding: migrate transcoding routines from OsmoBTS

There are some projects, such as GR-GSM and OsmocomBB, which would
benefit from using one shared implementation of GSM 05.03 code. So,
this commit introduces a new sub-library called libosmocoding, which
(for now) provides GSM, GPRS and EDGE transcoding routines, migrated
from OsmoBTS.

The original GSM 05.03 code from OsmoBTS was relicensed under
GPLv2-or-later with permission of copyright holders (Andreas Eversberg,
Alexander Chemeris and Tom Tsou).

The following data types are currently supported:

 - xCCH
 - PDTCH (CS 1-4 and MCS 1-9)
 - TCH/FR
 - TCH/HR
 - TCH/AFS
 - RCH/AHS
 - RACH
 - SCH

Change-Id: I0c3256b87686d878e4e716d12393cad5924fdfa1
changes/33/933/16
Vadim Yanitskiy 2016-09-23 01:48:59 +07:00
parent 68930e85b5
commit 3262f820b5
25 changed files with 8111 additions and 7 deletions

3
.gitignore vendored
View File

@ -36,6 +36,7 @@ Doxyfile.core
Doxyfile.gsm
Doxyfile.vty
Doxyfile.codec
Doxyfile.coding
debian/autoreconf.after
debian/autoreconf.before
@ -73,6 +74,7 @@ tests/bits/bitrev_test
tests/a5/a5_test
tests/comp128/comp128_test
tests/auth/milenage_test
tests/coding/coding_test
tests/conv/conv_test
tests/lapd/lapd_test
tests/gsm0808/gsm0808_test
@ -105,6 +107,7 @@ utils/osmo-auc-gen
utils/osmo-sim-test
doc/codec
doc/coding
doc/core
doc/vty/latex
doc/vty/html

1716
Doxyfile.coding.in Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
SUBDIRS = include src src/vty src/codec src/gsm src/gb src/ctrl src/sim tests utils
SUBDIRS = include src src/vty src/codec src/gsm src/coding src/gb src/ctrl src/sim tests utils
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libosmocore.pc libosmocodec.pc libosmovty.pc libosmogsm.pc \
libosmogb.pc libosmoctrl.pc
libosmogb.pc libosmoctrl.pc libosmocoding.pc
BUILT_SOURCES = $(top_srcdir)/.version
$(top_srcdir)/.version:
@ -22,7 +22,8 @@ html_DATA = $(top_builddir)/doc/html.tar
$(html_DATA): $(top_builddir)/doc/core/html/index.html \
$(top_builddir)/doc/gsm/html/index.html \
$(top_builddir)/doc/vty/html/index.html \
$(top_builddir)/doc/codec/html/index.html
$(top_builddir)/doc/codec/html/index.html \
$(top_builddir)/doc/coding/html/index.html
cd $(top_builddir)/doc && tar cf html.tar */html
$(top_builddir)/doc/core/html/index.html: $(SOURCES) Doxyfile.core
@ -44,13 +45,18 @@ $(top_builddir)/doc/codec/html/index.html: $(SOURCES) Doxyfile.codec
mkdir -p doc/codec
$(DOXYGEN) Doxyfile.codec
$(top_builddir)/doc/coding/html/index.html: Doxyfile.coding
@rm -rf doc/coding
mkdir -p doc/coding
$(DOXYGEN) Doxyfile.coding
install-data-hook:
cd $(DESTDIR)$(htmldir) && tar xf html.tar && rm -f html.tar
uninstall-hook:
cd $(DESTDIR)$(htmldir) && rm -rf {core,gsm,vty,codec}
cd $(DESTDIR)$(htmldir) && rm -rf {core,gsm,vty,codec,coding}
DX_CLEAN = doc/{core,gsm,vty,codec}/html/search/* doc/{core,gsm,vty,codec}/{html,latex}/* doc/html.tar doc/{core,gsm,vty,codec}/doxygen_sqlite3.db doc/*.tag
DX_CLEAN = doc/{core,gsm,vty,codec,coding}/html/search/* doc/{core,gsm,vty,codec,coding}/{html,latex}/* doc/html.tar doc/{core,gsm,vty,codec,coding}/doxygen_sqlite3.db doc/*.tag
endif
MOSTLYCLEANFILES = $(DX_CLEAN)

View File

@ -42,6 +42,7 @@ case $host in
*)
LTLDFLAGS_OSMOGB='-Wl,--version-script=$(srcdir)/libosmogb.map'
LTLDFLAGS_OSMOGSM='-Wl,--version-script=$(srcdir)/libosmogsm.map'
LTLDFLAGS_OSMOCODING='-Wl,--version-script=$(srcdir)/libosmocoding.map'
;;
esac
AC_SUBST(LTLDFLAGS_OSMOGB)
@ -228,6 +229,7 @@ fi
AC_OUTPUT(
libosmocore.pc
libosmocodec.pc
libosmocoding.pc
libosmovty.pc
libosmogsm.pc
libosmogb.pc
@ -237,6 +239,7 @@ AC_OUTPUT(
src/Makefile
src/vty/Makefile
src/codec/Makefile
src/coding/Makefile
src/sim/Makefile
src/gsm/Makefile
src/gb/Makefile
@ -248,4 +251,5 @@ AC_OUTPUT(
Doxyfile.gsm
Doxyfile.vty
Doxyfile.codec
Doxyfile.coding
Makefile)

34
debian/control vendored
View File

@ -25,6 +25,7 @@ Section: libs
Architecture: any
Multi-Arch: foreign
Depends: libosmocodec0 (= ${binary:Version}),
libosmocoding0 (= ${binary:Version}),
libosmocore8 (= ${binary:Version}),
libosmogb4 (= ${binary:Version}),
libosmogsm7 (= ${binary:Version}),
@ -76,6 +77,38 @@ Description: Documentation for the osmo codec library
.
This package contains the documentation for the libosmocodec library.
Package: libosmocoding0
Section: libs
Architecture: any
Multi-Arch: same
Depends: ${shlibs:Depends},
${misc:Depends}
Pre-Depends: ${misc:Pre-Depends}
Description: Osmo coding library
This is part of the libosmocore "meta"-library. The libosmocore library
contains various utility functions that were originally developed as part of
the OpenBSC project, but which are of a more generic nature and thus useful to
(at least) other programs that are developed in the sphere of Free Software /
Open Source mobile communication.
.
The libosmocoding library in particular contains the implementation of
GSM, GPRS and EDGE transcoding routines, migrated from OsmoBTS.
Package: libosmocoding-doc
Architecture: all
Section: doc
Depends: ${misc:Depends},
libosmocoding0,
libjs-jquery
Description: Documentation for the osmo coding library
This is part of the libosmocore "meta"-library. The libosmocore library
contains various utility functions that were originally developed as part of
the OpenBSC project, but which are of a more generic nature and thus useful to
(at least) other programs that are developed in the sphere of Free Software /
Open Source mobile communication.
.
This package contains the documentation for the libosmocoding library.
Package: libosmocore8
Section: libs
Architecture: any
@ -100,6 +133,7 @@ Depends: ${misc:Depends},
libosmocore8,
libjs-jquery,
libosmocodec-doc,
libosmocoding-doc,
libosmogsm-doc,
libosmovty-doc
Description: Documentation for the Osmo Core library

View File

@ -69,6 +69,11 @@ nobase_include_HEADERS = \
osmocom/gsm/gsm0480.h \
osmocom/gsm/gsm0502.h \
osmocom/gsm/gsm0503.h \
osmocom/coding/gsm0503_tables.h \
osmocom/coding/gsm0503_parity.h \
osmocom/coding/gsm0503_mapping.h \
osmocom/coding/gsm0503_interleaving.h \
osmocom/coding/gsm0503_coding.h \
osmocom/gsm/gsm0808.h \
osmocom/gsm/gsm23003.h \
osmocom/gsm/gsm48.h \

View File

@ -0,0 +1,63 @@
#pragma once
#include <stdint.h>
#include <osmocom/core/bits.h>
#define GSM0503_GPRS_BURSTS_NBITS (116 * 4)
#define GSM0503_EGPRS_BURSTS_NBITS (348 * 4)
#define NUM_BYTES(N) ((N + 8 - 1) / 8)
enum gsm0503_egprs_mcs {
EGPRS_MCS0,
EGPRS_MCS1,
EGPRS_MCS2,
EGPRS_MCS3,
EGPRS_MCS4,
EGPRS_MCS5,
EGPRS_MCS6,
EGPRS_MCS7,
EGPRS_MCS8,
EGPRS_MCS9,
EGPRS_NUM_MCS,
};
int gsm0503_xcch_encode(ubit_t *bursts, uint8_t *l2_data);
int gsm0503_xcch_decode(uint8_t *l2_data, sbit_t *bursts,
int *n_errors, int *n_bits_total);
int gsm0503_pdtch_encode(ubit_t *bursts, uint8_t *l2_data, uint8_t l2_len);
int gsm0503_pdtch_decode(uint8_t *l2_data, sbit_t *bursts, uint8_t *usf_p,
int *n_errors, int *n_bits_total);
int gsm0503_pdtch_egprs_encode(ubit_t *bursts, uint8_t *l2_data,
uint8_t l2_len);
int gsm0503_pdtch_egprs_decode(uint8_t *l2_data, sbit_t *bursts,
uint16_t nbits, uint8_t *usf_p, int *n_errors, int *n_bits_total);
int gsm0503_tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len,
int net_order);
int gsm0503_tch_fr_decode(uint8_t *tch_data, sbit_t *bursts, int net_order,
int efr, int *n_errors, int *n_bits_total);
int gsm0503_tch_hr_encode(ubit_t *bursts, uint8_t *tch_data, int len);
int gsm0503_tch_hr_decode(uint8_t *tch_data, sbit_t *bursts, int odd,
int *n_errors, int *n_bits_total);
int gsm0503_tch_afs_encode(ubit_t *bursts, uint8_t *tch_data, int len,
int codec_mode_req, uint8_t *codec, int codecs, uint8_t ft,
uint8_t cmr);
int gsm0503_tch_afs_decode(uint8_t *tch_data, sbit_t *bursts,
int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft,
uint8_t *cmr, int *n_errors, int *n_bits_total);
int gsm0503_tch_ahs_encode(ubit_t *bursts, uint8_t *tch_data, int len,
int codec_mode_req, uint8_t *codec, int codecs, uint8_t ft, uint8_t cmr);
int gsm0503_tch_ahs_decode(uint8_t *tch_data, sbit_t *bursts, int odd,
int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft,
uint8_t *cmr, int *n_errors, int *n_bits_total);
int gsm0503_rach_encode(ubit_t *burst, uint8_t *ra, uint8_t bsic);
int gsm0503_rach_decode(uint8_t *ra, sbit_t *burst, uint8_t bsic);
int gsm0503_sch_encode(ubit_t *burst, uint8_t *sb_info);
int gsm0503_sch_decode(uint8_t *sb_info, sbit_t *burst);

View File

@ -0,0 +1,51 @@
#pragma once
#include <osmocom/core/bits.h>
void gsm0503_xcch_deinterleave(sbit_t *cB, const sbit_t *iB);
void gsm0503_xcch_interleave(ubit_t *cB, ubit_t *iB);
void gsm0503_tch_fr_deinterleave(sbit_t *cB, sbit_t *iB);
void gsm0503_tch_fr_interleave(ubit_t *cB, ubit_t *iB);
void gsm0503_tch_hr_deinterleave(sbit_t *cB, sbit_t *iB);
void gsm0503_tch_hr_interleave(ubit_t *cB, ubit_t *iB);
void gsm0503_mcs1_ul_deinterleave(sbit_t *hc, sbit_t *dc, const sbit_t *iB);
void gsm0503_mcs1_ul_interleave(const ubit_t *hc,
const ubit_t *dc, ubit_t *iB);
void gsm0503_mcs1_dl_deinterleave(sbit_t *u, sbit_t *hc,
sbit_t *dc, const sbit_t *iB);
void gsm0503_mcs1_dl_interleave(const ubit_t *up, const ubit_t *hc,
const ubit_t *dc, ubit_t *iB);
void gsm0503_mcs5_ul_deinterleave(sbit_t *hc, sbit_t *dc,
const sbit_t *hi, const sbit_t *di);
void gsm0503_mcs5_ul_interleave(const ubit_t *hc, const ubit_t *dc,
ubit_t *hi, ubit_t *di);
void gsm0503_mcs5_dl_deinterleave(sbit_t *hc, sbit_t *dc,
const sbit_t *hi, const sbit_t *di);
void gsm0503_mcs5_dl_interleave(const ubit_t *hc, const ubit_t *dc,
ubit_t *hi, ubit_t *di);
void gsm0503_mcs7_ul_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
const sbit_t *hi, const sbit_t *di);
void gsm0503_mcs7_ul_interleave(const ubit_t *hc, const ubit_t *c1,
const ubit_t *c2, ubit_t *hi, ubit_t *di);
void gsm0503_mcs7_dl_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
const sbit_t *hi, const sbit_t *di);
void gsm0503_mcs7_dl_interleave(const ubit_t *hc, const ubit_t *c1,
const ubit_t *c2, ubit_t *hi, ubit_t *di);
void gsm0503_mcs8_ul_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
const sbit_t *hi, const sbit_t *di);
void gsm0503_mcs8_ul_interleave(const ubit_t *hc, const ubit_t *c1,
const ubit_t *c2, ubit_t *hi, ubit_t *di);
void gsm0503_mcs8_dl_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
const sbit_t *hi, const sbit_t *di);
void gsm0503_mcs8_dl_interleave(const ubit_t *hc, const ubit_t *c1,
const ubit_t *c2, ubit_t *hi, ubit_t *di);

View File

@ -0,0 +1,33 @@
#pragma once
#include <osmocom/core/bits.h>
void gsm0503_xcch_burst_unmap(sbit_t *iB, const sbit_t *eB,
sbit_t *hl, sbit_t *hn);
void gsm0503_xcch_burst_map(ubit_t *iB, ubit_t *eB, const ubit_t *hl,
const ubit_t *hn);
void gsm0503_tch_burst_unmap(sbit_t *iB, sbit_t *eB, sbit_t *h, int odd);
void gsm0503_tch_burst_map(ubit_t *iB, ubit_t *eB, const ubit_t *h, int odd);
void gsm0503_mcs5_ul_burst_map(const ubit_t *di, ubit_t *eB,
const ubit_t *hi, int B);
void gsm0503_mcs5_ul_burst_unmap(sbit_t *di, const sbit_t *eB,
sbit_t *hi, int B);
void gsm0503_mcs7_ul_burst_map(const ubit_t *di, ubit_t *eB,
const ubit_t *hi, int B);
void gsm0503_mcs7_ul_burst_unmap(sbit_t *di, const sbit_t *eB,
sbit_t *hi, int B);
void gsm0503_mcs5_dl_burst_map(const ubit_t *di, ubit_t *eB,
const ubit_t *hi, const ubit_t *up, int B);
void gsm0503_mcs5_dl_burst_unmap(sbit_t *di, const sbit_t *eB,
sbit_t *hi, sbit_t *up, int B);
void gsm0503_mcs7_dl_burst_map(const ubit_t *di, ubit_t *eB,
const ubit_t *hi, const ubit_t *up, int B);
void gsm0503_mcs7_dl_burst_unmap(sbit_t *di, const sbit_t *eB,
sbit_t *hi, sbit_t *up, int B);
void gsm0503_mcs5_burst_swap(sbit_t *eB);

View File

@ -0,0 +1,13 @@
#pragma once
#include <osmocom/core/crcgen.h>
const struct osmo_crc64gen_code gsm0503_fire_crc40;
const struct osmo_crc16gen_code gsm0503_cs234_crc16;
const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr;
const struct osmo_crc16gen_code gsm0503_mcs_crc12;
const struct osmo_crc8gen_code gsm0503_rach_crc6;
const struct osmo_crc16gen_code gsm0503_sch_crc10;
const struct osmo_crc8gen_code gsm0503_tch_fr_crc3;
const struct osmo_crc8gen_code gsm0503_tch_efr_crc8;
const struct osmo_crc8gen_code gsm0503_amr_crc6;

View File

@ -0,0 +1,50 @@
#pragma once
#include <stdint.h>
#include <osmocom/core/bits.h>
extern const ubit_t gsm0503_pdtch_hl_hn_ubit[4][8];
extern const ubit_t gsm0503_pdtch_edge_hl_hn_ubit[3][8];
extern const sbit_t gsm0503_pdtch_hl_hn_sbit[4][8];
extern const sbit_t gsm0503_pdtch_edge_hl_hn_sbit[3][8];
extern const ubit_t gsm0503_usf2six[8][6];
extern const ubit_t gsm0503_usf2twelve_ubit[8][12];
extern const sbit_t gsm0503_usf2twelve_sbit[8][12];
extern const uint8_t gsm0503_puncture_cs2[588];
extern const uint8_t gsm0503_puncture_cs3[676];
extern const uint8_t gsm0503_puncture_mcs1_dl_hdr[108];
extern const uint8_t gsm0503_puncture_mcs1_ul_hdr[117];
extern const uint8_t gsm0503_puncture_mcs1_p1[588];
extern const uint8_t gsm0503_puncture_mcs1_p2[588];
extern const uint8_t gsm0503_puncture_mcs2_p1[732];
extern const uint8_t gsm0503_puncture_mcs2_p2[732];
extern const uint8_t gsm0503_puncture_mcs3_p1[948];
extern const uint8_t gsm0503_puncture_mcs3_p2[948];
extern const uint8_t gsm0503_puncture_mcs3_p3[948];
extern const uint8_t gsm0503_puncture_mcs4_p1[1116];
extern const uint8_t gsm0503_puncture_mcs4_p2[1116];
extern const uint8_t gsm0503_puncture_mcs4_p3[1116];
extern const uint8_t gsm0503_puncture_mcs5_p1[1404];
extern const uint8_t gsm0503_puncture_mcs5_p2[1404];
extern const uint8_t gsm0503_puncture_mcs6_p1[1836];
extern const uint8_t gsm0503_puncture_mcs6_p2[1836];
extern const uint8_t gsm0503_puncture_mcs7_dl_hdr[135];
extern const uint8_t gsm0503_puncture_mcs7_ul_hdr[162];
extern const uint8_t gsm0503_puncture_mcs7_p1[1404];
extern const uint8_t gsm0503_puncture_mcs7_p2[1404];
extern const uint8_t gsm0503_puncture_mcs7_p3[1404];
extern const uint8_t gsm0503_puncture_mcs8_p1[1692];
extern const uint8_t gsm0503_puncture_mcs8_p2[1692];
extern const uint8_t gsm0503_puncture_mcs8_p3[1692];
extern const uint8_t gsm0503_puncture_mcs9_p1[1836];
extern const uint8_t gsm0503_puncture_mcs9_p2[1836];
extern const uint8_t gsm0503_puncture_mcs9_p3[1836];
extern const uint16_t gsm0503_interleave_mcs5[1248];
extern const uint8_t gsm0503_gsm_fr_map[76];
extern const uint8_t gsm0503_gsm_efr_protected_bits[65];
extern const ubit_t gsm0503_afs_ic_ubit[4][8];
extern const sbit_t gsm0503_afs_ic_sbit[4][8];
extern const ubit_t gsm0503_ahs_ic_ubit[4][4];
extern const sbit_t gsm0503_ahs_ic_sbit[4][4];
extern const uint8_t gsm0503_tch_hr_interleaving[228][2];
extern const ubit_t gsm0503_mcs5_usf_precode_table[8][36];

11
libosmocoding.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: Osmocom L1 transcoding Library
Description: C Utility Library
Version: @VERSION@
Libs: -L${libdir} -losmocoding -losmocodec -losmogsm -losmocore
Cflags: -I${includedir}/

27
src/coding/Makefile.am Normal file
View File

@ -0,0 +1,27 @@
# This is _NOT_ the library release version, it's an API version.
# Please read Chapter 6 "Library interface versions" of the libtool
# documentation before making any modification
LIBVERSION = 0:0:0
AM_CPPFLAGS = -I$(top_srcdir)/include $(TALLOC_CFLAGS)
AM_CFLAGS = -Wall
lib_LTLIBRARIES = libosmocoding.la
libosmocoding_la_SOURCES = \
gsm0503_interleaving.c \
gsm0503_mapping.c \
gsm0503_tables.c \
gsm0503_parity.c \
gsm0503_coding.c
libosmocoding_la_LDFLAGS = \
-version-info \
$(LIBVERSION) \
-no-undefined \
$(TALLOC_LIBS)
libosmocoding_la_LIBADD = \
../libosmocore.la \
../gsm/libosmogsm.la \
../codec/libosmocodec.la
EXTRA_DIST = libosmocoding.map

2681
src/coding/gsm0503_coding.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,573 @@
/*
* (C) 2013 by Andreas Eversberg <jolly@eversberg.eu>
* (C) 2016 by Tom Tsou <tom.tsou@ettus.com>
*
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdint.h>
#include <string.h>
#include <osmocom/core/bits.h>
#include <osmocom/coding/gsm0503_tables.h>
#include <osmocom/coding/gsm0503_interleaving.h>
/*
* GSM xCCH interleaving and burst mapping
*
* Interleaving:
*
* Given 456 coded input bits, form 4 blocks of 114 bits:
*
* i(B, j) = c(n, k) k = 0, ..., 455
* n = 0, ..., N, N + 1, ...
* B = B_0 + 4n + (k mod 4)
* j = 2(49k mod 57) + ((k mod 8) div 4)
*
* Mapping on Burst:
*
* e(B, j) = i(B, j)
* e(B, 59 + j) = i(B, 57 + j) j = 0, ..., 56
* e(B, 57) = h_l(B)
* e(B, 58) = h_n(B)
*
* Where hl(B) and hn(B) are bits in burst B indicating flags.
*/
void gsm0503_xcch_deinterleave(sbit_t *cB, const sbit_t *iB)
{
int j, k, B;
for (k = 0; k < 456; k++) {
B = k & 3;
j = 2 * ((49 * k) % 57) + ((k & 7) >> 2);
cB[k] = iB[B * 114 + j];
}
}
void gsm0503_xcch_interleave(ubit_t *cB, ubit_t *iB)
{
int j, k, B;
for (k = 0; k < 456; k++) {
B = k & 3;
j = 2 * ((49 * k) % 57) + ((k & 7) >> 2);
iB[B * 114 + j] = cB[k];
}
}
void gsm0503_mcs1_dl_deinterleave(sbit_t *u, sbit_t *hc,
sbit_t *dc, const sbit_t *iB)
{
int k;
sbit_t c[452];
sbit_t cp[456];
gsm0503_xcch_deinterleave(cp, iB);
for (k = 0; k < 25; k++)
c[k] = cp[k];
for (k = 26; k < 82; k++)
c[k - 1] = cp[k];
for (k = 83; k < 139; k++)
c[k - 2] = cp[k];
for (k = 140; k < 424; k++)
c[k - 3] = cp[k];
for (k = 425; k < 456; k++)
c[k - 4] = cp[k];
if (u) {
for (k = 0; k < 12; k++)
u[k] = c[k];
}
if (hc) {
for (k = 12; k < 80; k++)
hc[k - 12] = c[k];
}
if (dc) {
for (k = 80; k < 452; k++)
dc[k - 80] = c[k];
}
}
void gsm0503_mcs1_dl_interleave(const ubit_t *up, const ubit_t *hc,
const ubit_t *dc, ubit_t *iB)
{
int k;
ubit_t c[452];
ubit_t cp[456];
for (k = 0; k < 12; k++)
c[k] = up[k];
for (k = 12; k < 80; k++)
c[k] = hc[k - 12];
for (k = 80; k < 452; k++)
c[k] = dc[k - 80];
for (k = 0; k < 25; k++)
cp[k] = c[k];
for (k = 26; k < 82; k++)
cp[k] = c[k - 1];
for (k = 83; k < 139; k++)
cp[k] = c[k - 2];
for (k = 140; k < 424; k++)
cp[k] = c[k - 3];
for (k = 425; k < 456; k++)
cp[k] = c[k - 4];
cp[25] = 0;
cp[82] = 0;
cp[139] = 0;
cp[424] = 0;
gsm0503_xcch_interleave(cp, iB);
}
void gsm0503_mcs1_ul_deinterleave(sbit_t *hc, sbit_t *dc, const sbit_t *iB)
{
int k;
sbit_t c[452];
sbit_t cp[456];
gsm0503_xcch_deinterleave(cp, iB);
for (k = 0; k < 25; k++)
c[k] = cp[k];
for (k = 26; k < 82; k++)
c[k - 1] = cp[k];
for (k = 83; k < 139; k++)
c[k - 2] = cp[k];
for (k = 140; k < 424; k++)
c[k - 3] = cp[k];
for (k = 425; k < 456; k++)
c[k - 4] = cp[k];
if (hc) {
for (k = 0; k < 80; k++)
hc[k] = c[k];
}
if (dc) {
for (k = 80; k < 452; k++)
dc[k - 80] = c[k];
}
}
void gsm0503_mcs1_ul_interleave(const ubit_t *hc, const ubit_t *dc, ubit_t *iB)
{
int k;
ubit_t c[452];
ubit_t cp[456];
for (k = 0; k < 80; k++)
c[k] = hc[k];
for (k = 80; k < 452; k++)
c[k] = dc[k - 80];
for (k = 0; k < 25; k++)
cp[k] = c[k];
for (k = 26; k < 82; k++)
cp[k] = c[k - 1];
for (k = 83; k < 139; k++)
cp[k] = c[k - 2];
for (k = 140; k < 424; k++)
cp[k] = c[k - 3];
for (k = 425; k < 456; k++)
cp[k] = c[k - 4];
cp[25] = 0;
cp[82] = 0;
cp[139] = 0;
cp[424] = 0;
gsm0503_xcch_interleave(cp, iB);
}
void gsm0503_mcs5_ul_interleave(const ubit_t *hc, const ubit_t *dc,
ubit_t *hi, ubit_t *di)
{
int j, k;
/* Header */
for (k = 0; k < 136; k++) {
j = 34 * (k % 4) + 2 * (11 * k % 17) + k % 8 / 4;
hi[j] = hc[k];
}
/* Data */
for (k = 0; k < 1248; k++) {
j = gsm0503_interleave_mcs5[k];
di[j] = dc[k];
}
}
void gsm0503_mcs5_ul_deinterleave(sbit_t *hc, sbit_t *dc,
const sbit_t *hi, const sbit_t *di)
{
int j, k;
/* Header */
if (hc) {
for (k = 0; k < 136; k++) {
j = 34 * (k % 4) + 2 * (11 * k % 17) + k % 8 / 4;
hc[k] = hi[j];
}
}
/* Data */
if (dc) {
for (k = 0; k < 1248; k++) {
j = gsm0503_interleave_mcs5[k];
dc[k] = di[j];
}
}
}
void gsm0503_mcs5_dl_interleave(const ubit_t *hc, const ubit_t *dc,
ubit_t *hi, ubit_t *di)
{
int j, k;
/* Header */
for (k = 0; k < 100; k++) {
j = 25 * (k % 4) + ((17 * k) % 25);
hi[j] = hc[k];
}
/* Data */
for (k = 0; k < 1248; k++) {
j = gsm0503_interleave_mcs5[k];
di[j] = dc[k];
}
}
void gsm0503_mcs5_dl_deinterleave(sbit_t *hc, sbit_t *dc,
const sbit_t *hi, const sbit_t *di)
{
int j, k;
/* Header */
if (hc) {
for (k = 0; k < 100; k++) {
j = 25 * (k % 4) + ((17 * k) % 25);
hc[k] = hi[j];
}
}
/* Data */
if (dc) {
for (k = 0; k < 1248; k++) {
j = gsm0503_interleave_mcs5[k];
dc[k] = di[j];
}
}
}
void gsm0503_mcs7_dl_interleave(const ubit_t *hc, const ubit_t *c1,
const ubit_t *c2, ubit_t *hi, ubit_t *di)
{
int j, k;
ubit_t dc[1224];
/* Header */
for (k = 0; k < 124; k++) {
j = 31 * (k % 4) + ((17 * k) % 31);
hi[j] = hc[k];
}
memcpy(&dc[0], c1, 612);
memcpy(&dc[612], c2, 612);
/* Data */
for (k = 0; k < 1224; k++) {
j = 306 * (k % 4) + 3 * (44 * k % 102 + k / 4 % 2) +
(k + 2 - k / 408) % 3;
di[j] = dc[k];
}
}
void gsm0503_mcs7_dl_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
const sbit_t *hi, const sbit_t *di)
{
int j, k;
ubit_t dc[1224];
/* Header */
if (hc) {
for (k = 0; k < 124; k++) {
j = 31 * (k % 4) + ((17 * k) % 31);
hc[k] = hi[j];
}
}
/* Data */
if (c1 && c2) {
for (k = 0; k < 1224; k++) {
j = 306 * (k % 4) + 3 * (44 * k % 102 + k / 4 % 2) +
(k + 2 - k / 408) % 3;
dc[k] = di[j];
}
memcpy(c1, &dc[0], 612);
memcpy(c2, &dc[612], 612);
}
}
void gsm0503_mcs7_ul_interleave(const ubit_t *hc, const ubit_t *c1,
const ubit_t *c2, ubit_t *hi, ubit_t *di)
{
int j, k;
ubit_t dc[1224];
/* Header */
for (k = 0; k < 160; k++) {
j = 40 * (k % 4) + 2 * (13 * (k / 8) % 20) + k % 8 / 4;
hi[j] = hc[k];
}
memcpy(&dc[0], c1, 612);
memcpy(&dc[612], c2, 612);
/* Data */
for (k = 0; k < 1224; k++) {
j = 306 * (k % 4) + 3 * (44 * k % 102 + k / 4 % 2) +
(k + 2 - k / 408) % 3;
di[j] = dc[k];
}
}
void gsm0503_mcs7_ul_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
const sbit_t *hi, const sbit_t *di)
{
int j, k;
ubit_t dc[1224];
/* Header */
if (hc) {
for (k = 0; k < 160; k++) {
j = 40 * (k % 4) + 2 * (13 * (k / 8) % 20) + k % 8 / 4;
hc[k] = hi[j];
}
}
/* Data */
if (c1 && c2) {
for (k = 0; k < 1224; k++) {
j = 306 * (k % 4) + 3 * (44 * k % 102 + k / 4 % 2) +
(k + 2 - k / 408) % 3;
dc[k] = di[j];
}
memcpy(c1, &dc[0], 612);
memcpy(c2, &dc[612], 612);
}
}
void gsm0503_mcs8_ul_interleave(const ubit_t *hc, const ubit_t *c1,
const ubit_t *c2, ubit_t *hi, ubit_t *di)
{
int j, k;
ubit_t dc[1224];
/* Header */
for (k = 0; k < 160; k++) {
j = 40 * (k % 4) + 2 * (13 * (k / 8) % 20) + k % 8 / 4;
hi[j] = hc[k];
}
memcpy(&dc[0], c1, 612);
memcpy(&dc[612], c2, 612);
/* Data */
for (k = 0; k < 1224; k++) {
j = 306 * (2 * (k / 612) + (k % 2)) +
3 * (74 * k % 102 + k / 2 % 2) + (k + 2 - k / 204) % 3;
di[j] = dc[k];
}
}
void gsm0503_mcs8_ul_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
const sbit_t *hi, const sbit_t *di)
{
int j, k;
ubit_t dc[1224];
/* Header */
if (hc) {
for (k = 0; k < 160; k++) {
j = 40 * (k % 4) + 2 * (13 * (k / 8) % 20) + k % 8 / 4;
hc[k] = hi[j];
}
}
/* Data */
if (c1 && c2) {
for (k = 0; k < 1224; k++) {
j = 306 * (2 * (k / 612) + (k % 2)) +
3 * (74 * k % 102 + k / 2 % 2) + (k + 2 - k / 204) % 3;
dc[k] = di[j];
}
memcpy(c1, &dc[0], 612);
memcpy(c2, &dc[612], 612);
}
}
void gsm0503_mcs8_dl_interleave(const ubit_t *hc, const ubit_t *c1,
const ubit_t *c2, ubit_t *hi, ubit_t *di)
{
int j, k;
ubit_t dc[1224];
/* Header */
for (k = 0; k < 124; k++) {
j = 31 * (k % 4) + ((17 * k) % 31);
hi[j] = hc[k];
}
memcpy(&dc[0], c1, 612);
memcpy(&dc[612], c2, 612);
/* Data */
for (k = 0; k < 1224; k++) {
j = 306 * (2 * (k / 612) + (k % 2)) +
3 * (74 * k % 102 + k / 2 % 2) + (k + 2 - k / 204) % 3;
di[j] = dc[k];
}
}
void gsm0503_mcs8_dl_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
const sbit_t *hi, const sbit_t *di)
{
int j, k;
ubit_t dc[1224];
/* Header */
if (hc) {
for (k = 0; k < 124; k++) {
j = 31 * (k % 4) + ((17 * k) % 31);
hc[k] = hi[j];
}
}
/* Data */
if (c1 && c2) {
for (k = 0; k < 1224; k++) {
j = 306 * (2 * (k / 612) + (k % 2)) +
3 * (74 * k % 102 + k / 2 % 2) + (k + 2 - k / 204) % 3;
dc[k] = di[j];
}
memcpy(c1, &dc[0], 612);
memcpy(c2, &dc[612], 612);
}
}
/*
* GSM TCH FR/EFR/AFS interleaving and burst mapping
*
* Interleaving:
*
* Given 456 coded input bits, form 8 blocks of 114 bits,
* where even bits of the first 4 blocks and odd bits of the last 4 blocks
* are used:
*
* i(B, j) = c(n, k) k = 0, ..., 455
* n = 0, ..., N, N + 1, ...
* B = B_0 + 4n + (k mod 8)
* j = 2(49k mod 57) + ((k mod 8) div 4)
*
* Mapping on Burst:
*
* e(B, j) = i(B, j)
* e(B, 59 + j) = i(B, 57 + j) j = 0, ..., 56
* e(B, 57) = h_l(B)
* e(B, 58) = h_n(B)
*
* Where hl(B) and hn(B) are bits in burst B indicating flags.
*/
void gsm0503_tch_fr_deinterleave(sbit_t *cB, sbit_t *iB)
{
int j, k, B;
for (k = 0; k < 456; k++) {
B = k & 7;
j = 2 * ((49 * k) % 57) + ((k & 7) >> 2);
cB[k] = iB[B * 114 + j];
}
}
void gsm0503_tch_fr_interleave(ubit_t *cB, ubit_t *iB)
{
int j, k, B;
for (k = 0; k < 456; k++) {
B = k & 7;
j = 2 * ((49 * k) % 57) + ((k & 7) >> 2);
iB[B * 114 + j] = cB[k];
}
}
/*
* GSM TCH HR/AHS interleaving and burst mapping
*
* Interleaving:
*
* Given 288 coded input bits, form 4 blocks of 114 bits,
* where even bits of the first 2 blocks and odd bits of the last 2 blocks
* are used:
*
* i(B, j) = c(n, k) k = 0, ..., 227
* n = 0, ..., N, N + 1, ...
* B = B_0 + 2n + b
* j, b = table[k];
*
* Mapping on Burst:
*
* e(B, j) = i(B, j)
* e(B, 59 + j) = i(B, 57 + j) j = 0, ..., 56
* e(B, 57) = h_l(B)
* e(B, 58) = h_n(B)
*
* Where hl(B) and hn(B) are bits in burst B indicating flags.
*/
void gsm0503_tch_hr_deinterleave(sbit_t *cB, sbit_t *iB)
{
int j, k, B;
for (k = 0; k < 228; k++) {
B = gsm0503_tch_hr_interleaving[k][1];
j = gsm0503_tch_hr_interleaving[k][0];
cB[k] = iB[B * 114 + j];
}
}
void gsm0503_tch_hr_interleave(ubit_t *cB, ubit_t *iB)
{
int j, k, B;
for (k = 0; k < 228; k++) {
B = gsm0503_tch_hr_interleaving[k][1];
j = gsm0503_tch_hr_interleaving[k][0];
iB[B * 114 + j] = cB[k];
}
}

View File

@ -0,0 +1,291 @@
/*
* (C) 2013 by Andreas Eversberg <jolly@eversberg.eu>
* (C) 2016 by Tom Tsou <tom.tsou@ettus.com>
*
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdint.h>
#include <string.h>
#include <osmocom/core/bits.h>
#include <osmocom/coding/gsm0503_mapping.h>
void gsm0503_xcch_burst_unmap(sbit_t *iB, const sbit_t *eB,
sbit_t *hl, sbit_t *hn)
{
memcpy(iB, eB, 57);
memcpy(iB + 57, eB + 59, 57);
if (hl)
*hl = eB[57];
if (hn)
*hn = eB[58];
}
void gsm0503_xcch_burst_map(ubit_t *iB, ubit_t *eB, const ubit_t *hl,
const ubit_t *hn)
{
memcpy(eB, iB, 57);
memcpy(eB + 59, iB + 57, 57);
if (hl)
eB[57] = *hl;
if (hn)
eB[58] = *hn;
}
void gsm0503_tch_burst_unmap(sbit_t *iB, sbit_t *eB, sbit_t *h, int odd)
{
int i;
/* brainfuck: only copy even or odd bits */
if (iB) {
for (i = odd; i < 57; i += 2)
iB[i] = eB[i];
for (i = 58 - odd; i < 114; i += 2)
iB[i] = eB[i + 2];
}
if (h) {
if (!odd)
*h = eB[58];
else
*h = eB[57];
}
}
void gsm0503_tch_burst_map(ubit_t *iB, ubit_t *eB, const ubit_t *h, int odd)
{
int i;
/* brainfuck: only copy even or odd bits */
if (eB) {
for (i = odd; i < 57; i += 2)
eB[i] = iB[i];
for (i = 58 - odd; i < 114; i += 2)
eB[i + 2] = iB[i];
}
if (h) {
if (!odd)
eB[58] = *h;
else
eB[57] = *h;
}
}
void gsm0503_mcs5_dl_burst_map(const ubit_t *di, ubit_t *eB,
const ubit_t *hi, const ubit_t *up, int B)
{
int j;
int q[8] = { 0, 0, 0, 0, 0, 0, 0, 0, };
for (j = 0; j < 156; j++)
eB[j] = di[312 * B + j];
for (j = 156; j < 168; j++)
eB[j] = hi[25 * B + j - 156];
for (j = 168; j < 174; j++)
eB[j] = up[9 * B + j - 168];
for (j = 174; j < 176; j++)
eB[j] = q[2 * B + j - 174];
for (j = 176; j < 179; j++)
eB[j] = up[9 * B + j - 170];
for (j = 179; j < 192; j++)
eB[j] = hi[25 * B + j - 167];
for (j = 192; j < 348; j++)
eB[j] = di[312 * B + j - 36];
}
void gsm0503_mcs5_dl_burst_unmap(sbit_t *di, const sbit_t *eB,
sbit_t *hi, sbit_t *up, int B)
{
int j;
for (j = 0; j < 156; j++)
di[312 * B + j] = eB[j];
for (j = 156; j < 168; j++)
hi[25 * B + j - 156] = eB[j];
for (j = 168; j < 174; j++)
up[9 * B + j - 168] = eB[j];
for (j = 176; j < 179; j++)
up[9 * B + j - 170] = eB[j];
for (j = 179; j < 192; j++)
hi[25 * B + j - 167] = eB[j];
for (j = 192; j < 348; j++)
di[312 * B + j - 36] = eB[j];
}
void gsm0503_mcs5_ul_burst_map(const ubit_t *di, ubit_t *eB,
const ubit_t *hi, int B)
{
int j;
for (j = 0; j < 156; j++)
eB[j] = di[312 * B + j];
for (j = 156; j < 174; j++)
eB[j] = hi[34 * B + j - 156];
for (j = 174; j < 176; j++)
eB[j] = 0;
for (j = 176; j < 192; j++)
eB[j] = hi[34 * B + j - 158];
for (j = 192; j < 348; j++)
eB[j] = di[312 * B + j - 36];
}
void gsm0503_mcs5_ul_burst_unmap(sbit_t *di, const sbit_t *eB,
sbit_t *hi, int B)
{
int j;
for (j = 0; j < 156; j++)
di[312 * B + j] = eB[j];
for (j = 156; j < 174; j++)
hi[34 * B + j - 156] = eB[j];
for (j = 176; j < 192; j++)
hi[34 * B + j - 158] = eB[j];
for (j = 192; j < 348; j++)
di[312 * B + j - 36] = eB[j];
}
void gsm0503_mcs7_dl_burst_map(const ubit_t *di, ubit_t *eB,
const ubit_t *hi, const ubit_t *up, int B)
{
int j;
int q[8] = { 1, 1, 1, 0, 0, 1, 1, 1, };
for (j = 0; j < 153; j++)
eB[j] = di[306 * B + j];
for (j = 153; j < 168; j++)
eB[j] = hi[31 * B + j - 153];
for (j = 168; j < 174; j++)
eB[j] = up[9 * B + j - 168];
for (j = 174; j < 176; j++)
eB[j] = q[2 * B + j - 174];
for (j = 176; j < 179; j++)
eB[j] = up[9 * B + j - 170];
for (j = 179; j < 195; j++)
eB[j] = hi[31 * B + j - 164];
for (j = 195; j < 348; j++)
eB[j] = di[306 * B + j - 42];
}
void gsm0503_mcs7_dl_burst_unmap(sbit_t *di, const sbit_t *eB,
sbit_t *hi, sbit_t *up, int B)
{
int j;
for (j = 0; j < 153; j++)
di[306 * B + j] = eB[j];
for (j = 153; j < 168; j++)
hi[31 * B + j - 153] = eB[j];
for (j = 168; j < 174; j++)
up[9 * B + j - 168] = eB[j];
for (j = 176; j < 179; j++)
up[9 * B + j - 170] = eB[j];
for (j = 179; j < 195; j++)
hi[31 * B + j - 164] = eB[j];
for (j = 195; j < 348; j++)
di[306 * B + j - 42] = eB[j];
}
void gsm0503_mcs7_ul_burst_map(const ubit_t *di, ubit_t *eB,
const ubit_t *hi, int B)
{
int j;
int q[8] = { 1, 1, 1, 0, 0, 1, 1, 1, };
for (j = 0; j < 153; j++)
eB[j] = di[306 * B + j];
for (j = 153; j < 174; j++)
eB[j] = hi[40 * B + j - 153];
for (j = 174; j < 176; j++)
eB[j] = q[2 * B + j - 174];
for (j = 176; j < 195; j++)
eB[j] = hi[40 * B + j - 155];
for (j = 195; j < 348; j++)
eB[j] = di[306 * B + j - 42];
}
void gsm0503_mcs7_ul_burst_unmap(sbit_t *di, const sbit_t *eB,
sbit_t *hi, int B)
{
int j;
for (j = 0; j < 153; j++)
di[306 * B + j] = eB[j];
for (j = 153; j < 174; j++)
hi[40 * B + j - 153] = eB[j];
for (j = 176; j < 195; j++)
hi[40 * B + j - 155] = eB[j];
for (j = 195; j < 348; j++)
di[306 * B + j - 42] = eB[j];
}
void gsm0503_mcs5_burst_swap(sbit_t *eB)
{
sbit_t t[14];
t[0] = eB[155];
t[1] = eB[158];
t[2] = eB[161];
t[3] = eB[164];
t[4] = eB[167];
t[5] = eB[170];
t[6] = eB[173];
t[7] = eB[195];
t[8] = eB[196];
t[9] = eB[198];
t[10] = eB[199];
t[11] = eB[201];
t[12] = eB[202];
t[13] = eB[204];
eB[155] = eB[142];
eB[158] = eB[144];
eB[161] = eB[145];
eB[164] = eB[147];
eB[167] = eB[148];
eB[170] = eB[150];
eB[173] = eB[151];
eB[195] = eB[176];
eB[196] = eB[179];
eB[198] = eB[182];
eB[199] = eB[185];
eB[201] = eB[188];
eB[202] = eB[191];
eB[204] = eB[194];
eB[142] = t[0];
eB[144] = t[1];
eB[145] = t[2];
eB[147] = t[3];
eB[148] = t[4];
eB[150] = t[5];
eB[151] = t[6];
eB[176] = t[7];
eB[179] = t[8];
eB[182] = t[9];
eB[185] = t[10];
eB[188] = t[11];
eB[191] = t[12];
eB[194] = t[13];
}

132
src/coding/gsm0503_parity.c Normal file
View File

@ -0,0 +1,132 @@
/*
* (C) 2013 by Andreas Eversberg <jolly@eversberg.eu>
* (C) 2016 by Tom Tsou <tom.tsou@ettus.com>
*
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdint.h>
#include <osmocom/core/crcgen.h>
#include <osmocom/coding/gsm0503_parity.h>
/*
* GSM (SACCH) parity (FIRE code)
*
* g(x) = (x^23 + 1)(x^17 + x^3 + 1)
* = x^40 + x^26 + x^23 + x^17 + x^3 + a1
*/
const struct osmo_crc64gen_code gsm0503_fire_crc40 = {
.bits = 40,
.poly = 0x0004820009ULL,
.init = 0x0000000000ULL,
.remainder = 0xffffffffffULL,
};
/*
* GSM PDTCH CS-2, CS-3, CS-4 parity
*
* g(x) = x^16 + x^12 + x^5 + 1
*/
const struct osmo_crc16gen_code gsm0503_cs234_crc16 = {
.bits = 16,
.poly = 0x1021,
.init = 0x0000,
.remainder = 0xffff,
};
/*
* EDGE MCS header parity
*
*/
const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr = {
.bits = 8,
.poly = 0x49,
.init = 0x00,
.remainder = 0xff,
};
/*
* EDGE MCS data parity
*
*/
const struct osmo_crc16gen_code gsm0503_mcs_crc12 = {
.bits = 12,
.poly = 0x0d31,
.init = 0x0000,
.remainder = 0x0fff,
};
/*
* GSM RACH parity
*
* g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1
*/
const struct osmo_crc8gen_code gsm0503_rach_crc6 = {
.bits = 6,
.poly = 0x2f,
.init = 0x00,
.remainder = 0x3f,
};
/*
* GSM SCH parity
*
* g(x) = x^10 + x^8 + x^6 + x^5 + x^4 + x^2 + 1
*/