<p>neels has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-bts/+/17377">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">osmo-bts-virtual: implement GSMTAP_CHANNEL_VOICE<br><br>This allows doing voice calls over virtphy. Only TCH/F tested so far.<br><br>Change-Id: I1cd9a251ce0b87181a0822d7940bbfc9f1428543<br>---<br>M src/osmo-bts-virtual/l1_if.c<br>M src/osmo-bts-virtual/scheduler_virtbts.c<br>2 files changed, 33 insertions(+), 17 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/77/17377/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c</span><br><span>index ab2cb76..fd7fa54 100644</span><br><span>--- a/src/osmo-bts-virtual/l1_if.c</span><br><span>+++ b/src/osmo-bts-virtual/l1_if.c</span><br><span>@@ -87,6 +87,7 @@</span><br><span>     uint8_t link_id;                        /* rsl link id tells if this is an ssociated or dedicated link */</span><br><span>    uint8_t chan_nr;                        /* encoded rsl channel type, timeslot and mf subslot */</span><br><span>      struct osmo_phsap_prim l1sap;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct msgb *msg_tch;</span><br><span> </span><br><span>    memset(&l1sap, 0, sizeof(l1sap));</span><br><span>        /* get rid of l1 gsmtap hdr */</span><br><span>@@ -128,12 +129,7 @@</span><br><span>                break;</span><br><span>       case GSMTAP_CHANNEL_TCH_F:</span><br><span>   case GSMTAP_CHANNEL_TCH_H:</span><br><span style="color: hsl(0, 100%, 40%);">-#if 0</span><br><span style="color: hsl(0, 100%, 40%);">-         /* TODO: handle voice messages */</span><br><span style="color: hsl(0, 100%, 40%);">-               if (!facch && ! tch_acch) {</span><br><span style="color: hsl(0, 100%, 40%);">-                     osmo_prim_init(&l1sap.oph, SAP_GSM_PH, PRIM_TCH, PRIM_OP_INDICATION, msg);</span><br><span style="color: hsl(0, 100%, 40%);">-          }</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(120, 100%, 40%);">+               /* This is TCH signalling, for voice frames see GSMTAP_CHANNEL_VOICE */</span><br><span>      case GSMTAP_CHANNEL_SDCCH4:</span><br><span>  case GSMTAP_CHANNEL_SDCCH8:</span><br><span>  case GSMTAP_CHANNEL_PACCH:</span><br><span>@@ -151,6 +147,14 @@</span><br><span>            l1sap.u.data.pdch_presence_info = PRES_INFO_BOTH;</span><br><span>            l1if_process_meas_res(pinst->trx, timeslot, fn, chan_nr, 0, 0, 0, 0);</span><br><span>             break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case GSMTAP_CHANNEL_VOICE:</span><br><span style="color: hsl(120, 100%, 40%);">+            msg_tch = msgb_alloc_headroom(sizeof(l1sap) + msg->len, sizeof(l1sap),</span><br><span style="color: hsl(120, 100%, 40%);">+                                           "virtphy-voice-frame-from-GSMTAP-to-Um");</span><br><span style="color: hsl(120, 100%, 40%);">+             msgb_put(msg_tch, msg->len);</span><br><span style="color: hsl(120, 100%, 40%);">+               memcpy(msg_tch->data, msg->data, msg->len);</span><br><span style="color: hsl(120, 100%, 40%);">+          add_l1sap_header(pinst->trx, msg_tch, NULL, chan_nr, fn,</span><br><span style="color: hsl(120, 100%, 40%);">+                            0, 10 * signal_dbm, 0, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+                return;</span><br><span>      case GSMTAP_CHANNEL_AGCH:</span><br><span>    case GSMTAP_CHANNEL_PCH:</span><br><span>     case GSMTAP_CHANNEL_BCCH:</span><br><span>diff --git a/src/osmo-bts-virtual/scheduler_virtbts.c b/src/osmo-bts-virtual/scheduler_virtbts.c</span><br><span>index 91d9153..aae78fe 100644</span><br><span>--- a/src/osmo-bts-virtual/scheduler_virtbts.c</span><br><span>+++ b/src/osmo-bts-virtual/scheduler_virtbts.c</span><br><span>@@ -51,8 +51,8 @@</span><br><span>  * This will at first wrap the msg with a GSMTAP header and then write it to the declared multicast socket.</span><br><span>  * TODO: we might want to remove unused argument uint8_t tn</span><br><span>  */</span><br><span style="color: hsl(0, 100%, 40%);">-static void tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,</span><br><span style="color: hsl(0, 100%, 40%);">-                        enum trx_chan_type chan, struct msgb *msg)</span><br><span style="color: hsl(120, 100%, 40%);">+static void _tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,</span><br><span style="color: hsl(120, 100%, 40%);">+                       enum trx_chan_type chan, struct msgb *msg, bool is_voice_frame)</span><br><span> {</span><br><span>      const struct trx_chan_desc *chdesc = &trx_chan_desc[chan];</span><br><span>       struct msgb *outmsg;                    /* msg to send with gsmtap header prepended */</span><br><span>@@ -69,9 +69,11 @@</span><br><span>  rsl_dec_chan_nr(chdesc->chan_nr, &rsl_chantype, &subslot, &timeslot);</span><br><span>         /* the timeslot is not encoded in the chan_nr of the chdesc, and so has to be overwritten */</span><br><span>         timeslot = tn;</span><br><span style="color: hsl(120, 100%, 40%);">+        if (is_voice_frame)</span><br><span style="color: hsl(120, 100%, 40%);">+           gsmtap_chantype = GSMTAP_CHANNEL_VOICE;</span><br><span>      /* in Osmocom, AGCH is only sent on ccch block 0. no idea why. this seems to cause false GSMTAP channel</span><br><span>       * types for agch and pch. */</span><br><span style="color: hsl(0, 100%, 40%);">-   if (rsl_chantype == RSL_CHAN_PCH_AGCH &&</span><br><span style="color: hsl(120, 100%, 40%);">+      else if (rsl_chantype == RSL_CHAN_PCH_AGCH &&</span><br><span>            l1sap_fn2ccch_block(fn) >= num_agch(l1t->trx, "PH-DATA-REQ"))</span><br><span>            gsmtap_chantype = GSMTAP_CHANNEL_PCH;</span><br><span>        else</span><br><span>@@ -104,6 +106,18 @@</span><br><span>  msgb_free(msg);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,</span><br><span style="color: hsl(120, 100%, 40%);">+                   enum trx_chan_type chan, struct msgb *msg)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       _tx_to_virt_um(l1t, tn, fn, chan, msg, false);</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%);">+static void tx_to_virt_um_voice_frame(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,</span><br><span style="color: hsl(120, 100%, 40%);">+                                enum trx_chan_type chan, struct msgb *msg)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   _tx_to_virt_um(l1t, tn, fn, chan, msg, true);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*</span><br><span>  * TX on downlink</span><br><span>  */</span><br><span>@@ -410,11 +424,10 @@</span><br><span>                 goto send_burst;</span><br><span>     }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   if (msg_facch) {</span><br><span style="color: hsl(120, 100%, 40%);">+      if (msg_facch)</span><br><span>               tx_to_virt_um(l1t, tn, fn, chan, msg_facch);</span><br><span style="color: hsl(0, 100%, 40%);">-            msgb_free(msg_tch);</span><br><span style="color: hsl(0, 100%, 40%);">-     } else</span><br><span style="color: hsl(0, 100%, 40%);">-          tx_to_virt_um(l1t, tn, fn, chan, msg_tch);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (msg_tch)</span><br><span style="color: hsl(120, 100%, 40%);">+          tx_to_virt_um_voice_frame(l1t, tn, fn, chan, msg_tch);</span><br><span> </span><br><span> send_burst:</span><br><span> </span><br><span>@@ -451,11 +464,10 @@</span><br><span>                goto send_burst;</span><br><span>     }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   if (msg_facch) {</span><br><span style="color: hsl(120, 100%, 40%);">+      if (msg_facch)</span><br><span>               tx_to_virt_um(l1t, tn, fn, chan, msg_facch);</span><br><span style="color: hsl(0, 100%, 40%);">-            msgb_free(msg_tch);</span><br><span style="color: hsl(0, 100%, 40%);">-     } else if (msg_tch)</span><br><span style="color: hsl(0, 100%, 40%);">-             tx_to_virt_um(l1t, tn, fn, chan, msg_tch);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (msg_tch)</span><br><span style="color: hsl(120, 100%, 40%);">+          tx_to_virt_um_voice_frame(l1t, tn, fn, chan, msg_tch);</span><br><span> </span><br><span> send_burst:</span><br><span>    return NULL;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bts/+/17377">change 17377</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/osmo-bts/+/17377"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bts </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I1cd9a251ce0b87181a0822d7940bbfc9f1428543 </div>
<div style="display:none"> Gerrit-Change-Number: 17377 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>