osmo-bts-virtual: implement GSMTAP_CHANNEL_VOICE

Change-Id: I1cd9a251ce0b87181a0822d7940bbfc9f1428543
This commit is contained in:
Neels Hofmeyr 2020-03-03 15:37:31 +01:00
parent f9e7ccce27
commit ff5537de50
2 changed files with 33 additions and 17 deletions

View File

@ -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:

View File

@ -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, &timeslot);
/* 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;