From ff5537de5011e7847f844ac738246829deee2064 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 3 Mar 2020 15:37:31 +0100 Subject: osmo-bts-virtual: implement GSMTAP_CHANNEL_VOICE Change-Id: I1cd9a251ce0b87181a0822d7940bbfc9f1428543 --- src/osmo-bts-virtual/l1_if.c | 16 +++++++++------ src/osmo-bts-virtual/scheduler_virtbts.c | 34 +++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c index ab2cb762..fd7fa540 100644 --- a/src/osmo-bts-virtual/l1_if.c +++ b/src/osmo-bts-virtual/l1_if.c @@ -87,6 +87,7 @@ static void virt_um_rcv_cb(struct virt_um_inst *vui, struct msgb *msg) uint8_t link_id; /* rsl link id tells if this is an ssociated or dedicated link */ uint8_t chan_nr; /* encoded rsl channel type, timeslot and mf subslot */ struct osmo_phsap_prim l1sap; + struct msgb *msg_tch; memset(&l1sap, 0, sizeof(l1sap)); /* get rid of l1 gsmtap hdr */ @@ -128,12 +129,7 @@ static void virt_um_rcv_cb(struct virt_um_inst *vui, struct msgb *msg) break; case GSMTAP_CHANNEL_TCH_F: case GSMTAP_CHANNEL_TCH_H: -#if 0 - /* TODO: handle voice messages */ - if (!facch && ! tch_acch) { - osmo_prim_init(&l1sap.oph, SAP_GSM_PH, PRIM_TCH, PRIM_OP_INDICATION, msg); - } -#endif + /* This is TCH signalling, for voice frames see GSMTAP_CHANNEL_VOICE */ case GSMTAP_CHANNEL_SDCCH4: case GSMTAP_CHANNEL_SDCCH8: case GSMTAP_CHANNEL_PACCH: @@ -151,6 +147,14 @@ static void virt_um_rcv_cb(struct virt_um_inst *vui, struct msgb *msg) l1sap.u.data.pdch_presence_info = PRES_INFO_BOTH; l1if_process_meas_res(pinst->trx, timeslot, fn, chan_nr, 0, 0, 0, 0); break; + case GSMTAP_CHANNEL_VOICE: + msg_tch = msgb_alloc_headroom(sizeof(l1sap) + msg->len, sizeof(l1sap), + "virtphy-voice-frame-from-GSMTAP-to-Um"); + msgb_put(msg_tch, msg->len); + memcpy(msg_tch->data, msg->data, msg->len); + add_l1sap_header(pinst->trx, msg_tch, NULL, chan_nr, fn, + 0, 10 * signal_dbm, 0, 0, 0); + return; case GSMTAP_CHANNEL_AGCH: case GSMTAP_CHANNEL_PCH: case GSMTAP_CHANNEL_BCCH: diff --git a/src/osmo-bts-virtual/scheduler_virtbts.c b/src/osmo-bts-virtual/scheduler_virtbts.c index 91d91539..aae78fe9 100644 --- a/src/osmo-bts-virtual/scheduler_virtbts.c +++ b/src/osmo-bts-virtual/scheduler_virtbts.c @@ -51,8 +51,8 @@ * This will at first wrap the msg with a GSMTAP header and then write it to the declared multicast socket. * TODO: we might want to remove unused argument uint8_t tn */ -static void tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, - enum trx_chan_type chan, struct msgb *msg) +static void _tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, + enum trx_chan_type chan, struct msgb *msg, bool is_voice_frame) { const struct trx_chan_desc *chdesc = &trx_chan_desc[chan]; struct msgb *outmsg; /* msg to send with gsmtap header prepended */ @@ -69,9 +69,11 @@ static void tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, rsl_dec_chan_nr(chdesc->chan_nr, &rsl_chantype, &subslot, ×lot); /* the timeslot is not encoded in the chan_nr of the chdesc, and so has to be overwritten */ timeslot = tn; + if (is_voice_frame) + gsmtap_chantype = GSMTAP_CHANNEL_VOICE; /* in Osmocom, AGCH is only sent on ccch block 0. no idea why. this seems to cause false GSMTAP channel * types for agch and pch. */ - if (rsl_chantype == RSL_CHAN_PCH_AGCH && + else if (rsl_chantype == RSL_CHAN_PCH_AGCH && l1sap_fn2ccch_block(fn) >= num_agch(l1t->trx, "PH-DATA-REQ")) gsmtap_chantype = GSMTAP_CHANNEL_PCH; else @@ -104,6 +106,18 @@ static void tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, msgb_free(msg); } +static void tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, + enum trx_chan_type chan, struct msgb *msg) +{ + _tx_to_virt_um(l1t, tn, fn, chan, msg, false); +} + +static void tx_to_virt_um_voice_frame(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, + enum trx_chan_type chan, struct msgb *msg) +{ + _tx_to_virt_um(l1t, tn, fn, chan, msg, true); +} + /* * TX on downlink */ @@ -410,11 +424,10 @@ ubit_t *tx_tchf_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, goto send_burst; } - if (msg_facch) { + if (msg_facch) tx_to_virt_um(l1t, tn, fn, chan, msg_facch); - msgb_free(msg_tch); - } else - tx_to_virt_um(l1t, tn, fn, chan, msg_tch); + if (msg_tch) + tx_to_virt_um_voice_frame(l1t, tn, fn, chan, msg_tch); send_burst: @@ -451,11 +464,10 @@ ubit_t *tx_tchh_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, goto send_burst; } - if (msg_facch) { + if (msg_facch) tx_to_virt_um(l1t, tn, fn, chan, msg_facch); - msgb_free(msg_tch); - } else if (msg_tch) - tx_to_virt_um(l1t, tn, fn, chan, msg_tch); + if (msg_tch) + tx_to_virt_um_voice_frame(l1t, tn, fn, chan, msg_tch); send_burst: return NULL; -- cgit v1.2.3