<p>laforge has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/18247">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Implement ITU-T I.460 multiplex / demultiplex<br><br>This implements a multiplexer and de-multiplexer for the ITU-T I.460<br>standard.  The latter covers the transmission of sub-slots of 32/16/8k<br>inside 64k timeslots.<br><br>Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda<br>---<br>M include/Makefile.am<br>A include/osmocom/gsm/i460_mux.h<br>M src/gsm/Makefile.am<br>M src/gsm/libosmogsm.map<br>4 files changed, 88 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/47/18247/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/Makefile.am b/include/Makefile.am</span><br><span>index 572c880..456b8ef 100644</span><br><span>--- a/include/Makefile.am</span><br><span>+++ b/include/Makefile.am</span><br><span>@@ -103,6 +103,7 @@</span><br><span>                        osmocom/gsm/gsm_utils.h \</span><br><span>                        osmocom/gsm/gsup.h \</span><br><span>                        osmocom/gsm/gsup_sms.h \</span><br><span style="color: hsl(120, 100%, 40%);">+                       osmocom/gsm/i460_mux.h \</span><br><span>                        osmocom/gsm/ipa.h \</span><br><span>                        osmocom/gsm/lapd_core.h \</span><br><span>                        osmocom/gsm/lapdm.h \</span><br><span>diff --git a/include/osmocom/gsm/i460_mux.h b/include/osmocom/gsm/i460_mux.h</span><br><span>new file mode 100644</span><br><span>index 0000000..759e392</span><br><span>--- /dev/null</span><br><span>+++ b/include/osmocom/gsm/i460_mux.h</span><br><span>@@ -0,0 +1,79 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#pragma once</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdint.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/bits.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/linuxlist.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/msgb.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* I.460 sub-slot rate */</span><br><span style="color: hsl(120, 100%, 40%);">+enum osmo_i460_rate {</span><br><span style="color: hsl(120, 100%, 40%);">+   OSMO_I460_RATE_NONE,            /* disabled */</span><br><span style="color: hsl(120, 100%, 40%);">+        OSMO_I460_RATE_64k,</span><br><span style="color: hsl(120, 100%, 40%);">+   OSMO_I460_RATE_32k,</span><br><span style="color: hsl(120, 100%, 40%);">+   OSMO_I460_RATE_16k,</span><br><span style="color: hsl(120, 100%, 40%);">+   OSMO_I460_RATE_8k,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+typedef void (*out_cb_bits_t)(void *user_data, const ubit_t *bits, unsigned int num_bits);</span><br><span style="color: hsl(120, 100%, 40%);">+typedef void (*out_cb_bytes_t)(void *user_data, const uint8_t *bytes, unsigned int num_bytes);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_i460_subchan_demux {</span><br><span style="color: hsl(120, 100%, 40%);">+      /*! bit-buffer for output bits */</span><br><span style="color: hsl(120, 100%, 40%);">+     uint8_t *out_bitbuf;</span><br><span style="color: hsl(120, 100%, 40%);">+  /*! size of out_bitbuf in bytes */</span><br><span style="color: hsl(120, 100%, 40%);">+    unsigned int out_bitbuf_size;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! offset of next bit to be written in out_bitbuf */</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int out_idx;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! callback to be called once we have received out_bitbuf_size bits */</span><br><span style="color: hsl(120, 100%, 40%);">+       out_cb_bits_t out_cb_bits;</span><br><span style="color: hsl(120, 100%, 40%);">+    out_cb_bytes_t out_cb_bytes;</span><br><span style="color: hsl(120, 100%, 40%);">+  void *user_data;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_i460_subchan_mux {</span><br><span style="color: hsl(120, 100%, 40%);">+        /*! list of to-be-transmitted message buffers */</span><br><span style="color: hsl(120, 100%, 40%);">+      struct llist_head tx_queue;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_i460_subchan {</span><br><span style="color: hsl(120, 100%, 40%);">+ enum osmo_i460_rate rate;               /* 8/16/32/64k */</span><br><span style="color: hsl(120, 100%, 40%);">+     uint8_t bit_offset;             /* bit offset inside each byte of the B-channel */</span><br><span style="color: hsl(120, 100%, 40%);">+    struct osmo_i460_subchan_demux demux;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct osmo_i460_subchan_mux mux;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_i460_timeslot {</span><br><span style="color: hsl(120, 100%, 40%);">+  struct osmo_i460_subchan schan[8];</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! description of a sub-channel; passed by caller */</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_i460_schan_desc {</span><br><span style="color: hsl(120, 100%, 40%);">+        enum osmo_i460_rate rate;</span><br><span style="color: hsl(120, 100%, 40%);">+     uint8_t bit_offset;</span><br><span style="color: hsl(120, 100%, 40%);">+   struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              /* size (in bits) of the internal buffer; determines granularity */</span><br><span style="color: hsl(120, 100%, 40%);">+           size_t num_bits;</span><br><span style="color: hsl(120, 100%, 40%);">+              /*! call-back function called whenever we received num_bits */</span><br><span style="color: hsl(120, 100%, 40%);">+                out_cb_bits_t out_cb_bits;</span><br><span style="color: hsl(120, 100%, 40%);">+            /*! out_cb_bytes call-back function called whenever we received num_bits.</span><br><span style="color: hsl(120, 100%, 40%);">+              * The user is usually expected to provide either out_cb_bits or out_cb_bytes.  If only</span><br><span style="color: hsl(120, 100%, 40%);">+                * out_cb_bits is provided, output data will always be provided as unpacked bits;  if only</span><br><span style="color: hsl(120, 100%, 40%);">+             * out_cb_bytes is provided, output data will always be provided as packet bits (bytes).  If</span><br><span style="color: hsl(120, 100%, 40%);">+           * both are provided, it is up to the I.460 multiplex to decide if it calls either of the two,</span><br><span style="color: hsl(120, 100%, 40%);">+                 * depending on what can be provided without extra conversion. */</span><br><span style="color: hsl(120, 100%, 40%);">+             out_cb_bytes_t out_cb_bytes;</span><br><span style="color: hsl(120, 100%, 40%);">+          /* opaque user data pointer to pass to out_cb */</span><br><span style="color: hsl(120, 100%, 40%);">+              void *user_data;</span><br><span style="color: hsl(120, 100%, 40%);">+      } demux;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void osmo_i460_demux_in(struct osmo_i460_timeslot *ts, const uint8_t *data, size_t data_len);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void osmo_i460_mux_enqueue(struct osmo_i460_subchan *schan, struct msgb *msg);</span><br><span style="color: hsl(120, 100%, 40%);">+int osmo_i460_mux_out(struct osmo_i460_timeslot *ts, uint8_t *out, size_t out_len);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void osmo_i460_ts_init(struct osmo_i460_timeslot *ts);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_i460_subchan *</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_i460_subchan_add(void *ctx, struct osmo_i460_timeslot *ts, const struct osmo_i460_schan_desc *chd);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void osmo_i460_subchan_del(struct osmo_i460_subchan *schan);</span><br><span>diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am</span><br><span>index 6935eab..eeb1164 100644</span><br><span>--- a/src/gsm/Makefile.am</span><br><span>+++ b/src/gsm/Makefile.am</span><br><span>@@ -32,7 +32,7 @@</span><br><span>                  milenage/milenage.c gan.c ipa.c gsm0341.c apn.c \</span><br><span>                    gsup.c gsup_sms.c gprs_gea.c gsm0503_conv.c oap.c gsm0808_utils.c \</span><br><span>                  gsm23003.c mncc.c bts_features.c oap_client.c \</span><br><span style="color: hsl(0, 100%, 40%);">-                 gsm29118.c gsm48_rest_octets.c cbsp.c gsm48049.c</span><br><span style="color: hsl(120, 100%, 40%);">+                      gsm29118.c gsm48_rest_octets.c cbsp.c gsm48049.c i460_mux.c</span><br><span> libgsmint_la_LDFLAGS = -no-undefined</span><br><span> libgsmint_la_LIBADD = $(top_builddir)/src/libosmocore.la</span><br><span> </span><br><span>diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map</span><br><span>index 1ff1286..372b0f1 100644</span><br><span>--- a/src/gsm/libosmogsm.map</span><br><span>+++ b/src/gsm/libosmogsm.map</span><br><span>@@ -664,5 +664,12 @@</span><br><span> osmo_cbsp_recv_buffered;</span><br><span> osmo_cbsp_errstr;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+osmo_i460_demux_in;</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_i460_mux_enqueue;</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_i460_mux_out;</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_i460_subchan_add;</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_i460_subchan_del;</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_i460_ts_init;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> local: *;</span><br><span> };</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/18247">change 18247</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/18247"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda </div>
<div style="display:none"> Gerrit-Change-Number: 18247 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>