fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-bts/+/38312?usp=email )
Change subject: l1sap: call csd_v110_rtp_decode() in l1sap_tch_rts_ind()
......................................................................
l1sap: call csd_v110_rtp_decode() in l1sap_tch_rts_ind()
The problem with calling csd_v110_rtp_decode() from l1sap_rtp_rx_cb()
is that we don't know in advance at which TDMA frame number the
resulting TCH block is going to be scheduled/transmitted. This
knowledge will be required in follow-up patches.
* In l1sap_rtp_rx_cb(): create an L1SAP msgb with the RTP payload
unmodified (160 bytes), like we do for speech frames.
* In l1sap_tch_rts_ind(): copy the RTP payload into a temporary
buffer on stack and call csd_v110_rtp_decode(), re-using the
L1SAP msgb as the output buffer.
This patch brings no functional changes, except that the DL RLP PDUs
now how the correct TDMA frame number in GSMTAP output (was always 0).
Related: OS#6578
Change-Id: Idca6807b1e49b89072683b9f00ff4e7cee44cf33
---
M src/common/l1sap.c
1 file changed, 104 insertions(+), 96 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/12/38312/1
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 68920a4..a8f2a04 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -426,6 +426,86 @@
return 0;
}
+/* process one MAC block of unpacked bits of a non-transparent CSD channel */
+static void gsmtap_csd_rlp_process(struct gsm_lchan *lchan, bool is_uplink,
+ const struct ph_tch_param *tch_ind,
+ const uint8_t *data, unsigned int data_len)
+{
+ struct gsm_bts_trx *trx = lchan->ts->trx;
+ struct gsmtap_inst *inst = trx->bts->gsmtap.inst;
+ struct osmo_rlp_frame_decoded rlpf;
+ pbit_t *rlp_buf;
+ uint16_t arfcn;
+ int byte_len;
+
+ if (!inst || !trx->bts->gsmtap.rlp)
+ return;
+
+ if (lchan->csd_mode != LCHAN_CSD_M_NT)
+ return;
+
+ if (is_uplink)
+ rlp_buf = lchan->tch.csd.rlp_buf_ul;
+ else
+ rlp_buf = lchan->tch.csd.rlp_buf_dl;
+
+ /* TCH/F 9.6: 4x60bit block => 240bit RLP frame
+ * TCH/F 4.8: 2x 2x60bit blocks starting at B0/B2/B4 => 240bit RLP frame
+ * TCH/H 4.8: 4x60bit block => 240bit RLP frame
+ * TCH/F 2.4: 2x36bit blocks => transparent only
+ * TCH/H 2.4: 4x36bit blocks => transparent only
+ * TCH/F 14.4: 2x 290 bit block (starting with M1=0) => 576-bit RLP frame
+ */
+
+ if (lchan->type == GSM_LCHAN_TCH_F && lchan->tch_mode ==
GSM48_CMODE_DATA_6k0) {
+ /* in this mode we have 120bit MAC blocks; two of them need to be concatenated
+ * to render a 240-bit RLP frame. The fist block is present in B0/B2/B4.
+ * The E7 bit is used to indicate the Frame MF0a */
+ OSMO_ASSERT(data_len == 120);
+ ubit_t e7 = data[4*7+3];
+ if (e7 == 0) {
+ /* E2=0: this is B0/B2/B4 containing the 1st half */
+ osmo_ubit2pbit_ext(rlp_buf, 0, data, 0, data_len, 1);
+ return;
+ } else {
+ /* E2=1: this is B1/B3/B5 containing the 2nd half */
+ osmo_ubit2pbit_ext(rlp_buf, 120, data, 0, data_len, 1);
+ byte_len = 240/8;
+ }
+ } else if (lchan->type == GSM_LCHAN_TCH_F && lchan->tch_mode ==
GSM48_CMODE_DATA_14k5) {
+ /* in this mode we have 290bit MAC blocks containing M1, M2 and 288 data bits;
+ * two of them need to be concatenated to render a
+ * 576-bit RLP frame. The start of a RLP frame is
+ * denoted by a block with M1-bit set to 0. */
+ OSMO_ASSERT(data_len == 290);
+ ubit_t m1 = data[0];
+ if (m1 == 0) {
+ osmo_ubit2pbit_ext(rlp_buf, 0, data, 2, data_len, 1);
+ return;
+ } else {
+ osmo_ubit2pbit_ext(rlp_buf, 288, data, 2, data_len, 1);
+ byte_len = 576/8;
+ }
+ } else {
+ byte_len = osmo_ubit2pbit_ext(rlp_buf, 0, data, 0, data_len, 1);
+ }
+
+ if (trx->bts->gsmtap.rlp_skip_null) {
+ int rc = osmo_rlp_decode(&rlpf, 0, rlp_buf, byte_len);
+ if (rc == 0 && rlpf.ftype == OSMO_RLP_FT_U && rlpf.u_ftype ==
OSMO_RLP_U_FT_NULL)
+ return;
+ }
+
+ arfcn = trx->arfcn;
+ if (is_uplink)
+ arfcn |= GSMTAP_ARFCN_F_UPLINK;
+
+ gsmtap_send_ex(inst, GSMTAP_TYPE_GSM_RLP, arfcn, lchan->ts->nr,
+ lchan->type == GSM_LCHAN_TCH_H ? GSMTAP_CHANNEL_VOICE_H :
GSMTAP_CHANNEL_VOICE_F,
+ lchan->nr, tch_ind->fn, tch_ind->rssi, 0, rlp_buf, byte_len);
+
+}
+
/* Paging Request 1 with "no identity" content, i.e. empty/dummy paging */
static const uint8_t paging_fill[GSM_MACBLOCK_LEN] = {
0x15, 0x06, 0x21, 0x00, 0x01, 0xf0, 0x2b, 0x2b, 0x2b, 0x2b,
@@ -1551,6 +1631,29 @@
resp_msg = NULL;
resp_l1sap = &empty_l1sap;
}
+ } else if (lchan->rsl_cmode == RSL_CMOD_SPD_DATA) {
+ uint8_t rtp[RFC4040_RTP_PLEN];
+
+ memcpy(&rtp[0], msgb_l2(resp_msg),
+ OSMO_MIN(msgb_l2len(resp_msg), sizeof(rtp)));
+ msgb_get(resp_msg, msgb_l2len(resp_msg));
+
+ int rc = csd_v110_rtp_decode(lchan, msgb_l2(resp_msg),
+ &rtp[0], sizeof(rtp));
+ if (rc > 0) {
+ msgb_put(resp_msg, rc);
+ /* 'fake' tch_ind containing all-zero so gsmtap code can be shared
+ * between UL and DL */
+ const struct ph_tch_param fake_tch_ind = { .fn = fn };
+ gsmtap_csd_rlp_process(lchan, false, &fake_tch_ind,
+ msgb_l2(resp_msg),
+ msgb_l2len(resp_msg));
+ } else {
+ rate_ctr_inc2(trx->bts->ctrs, BTS_CTR_RTP_RX_DROP_V110_DEC);
+ msgb_free(resp_msg);
+ resp_msg = NULL;
+ resp_l1sap = &empty_l1sap;
+ }
}
}
@@ -1850,84 +1953,6 @@
return 1;
}
-/* process one MAC block of unpacked bits of a non-transparent CSD channel */
-static void gsmtap_csd_rlp_process(struct gsm_lchan *lchan, bool is_uplink,
- const struct ph_tch_param *tch_ind,
- const uint8_t *data, unsigned int data_len)
-{
- struct gsm_bts_trx *trx = lchan->ts->trx;
- struct gsmtap_inst *inst = trx->bts->gsmtap.inst;
- struct osmo_rlp_frame_decoded rlpf;
- pbit_t *rlp_buf;
- uint16_t arfcn;
- int byte_len;
-
- if (!inst || !trx->bts->gsmtap.rlp)
- return;
-
- if (lchan->csd_mode != LCHAN_CSD_M_NT)
- return;
-
- if (is_uplink)
- rlp_buf = lchan->tch.csd.rlp_buf_ul;
- else
- rlp_buf = lchan->tch.csd.rlp_buf_dl;
-
- /* TCH/F 9.6: 4x60bit block => 240bit RLP frame
- * TCH/F 4.8: 2x 2x60bit blocks starting at B0/B2/B4 => 240bit RLP frame
- * TCH/H 4.8: 4x60bit block => 240bit RLP frame
- * TCH/F 2.4: 2x36bit blocks => transparent only
- * TCH/H 2.4: 4x36bit blocks => transparent only
- * TCH/F 14.4: 2x 290 bit block (starting with M1=0) => 576-bit RLP frame
- */
-
- if (lchan->type == GSM_LCHAN_TCH_F && lchan->tch_mode ==
GSM48_CMODE_DATA_6k0) {
- /* in this mode we have 120bit MAC blocks; two of them need to be concatenated
- * to render a 240-bit RLP frame. The fist block is present in B0/B2/B4.
- * The E7 bit is used to indicate the Frame MF0a */
- OSMO_ASSERT(data_len == 120);
- ubit_t e7 = data[4*7+3];
- if (e7 == 0) {
- osmo_ubit2pbit_ext(rlp_buf, 0, data, 0, data_len, 1);
- return;
- } else {
- osmo_ubit2pbit_ext(rlp_buf, 120, data, 0, data_len, 1);
- byte_len = 240/8;
- }
- } else if (lchan->type == GSM_LCHAN_TCH_F && lchan->tch_mode ==
GSM48_CMODE_DATA_14k5) {
- /* in this mode we have 290bit MAC blocks containing M1, M2 and 288 data bits;
- * two of them need to be concatenated to render a
- * 576-bit RLP frame. The start of a RLP frame is
- * denoted by a block with M1-bit set to 0. */
- OSMO_ASSERT(data_len == 290);
- ubit_t m1 = data[0];
- if (m1 == 0) {
- osmo_ubit2pbit_ext(rlp_buf, 0, data, 2, data_len, 1);
- return;
- } else {
- osmo_ubit2pbit_ext(rlp_buf, 288, data, 2, data_len, 1);
- byte_len = 576/8;
- }
- } else {
- byte_len = osmo_ubit2pbit_ext(rlp_buf, 0, data, 0, data_len, 1);
- }
-
- if (trx->bts->gsmtap.rlp_skip_null) {
- int rc = osmo_rlp_decode(&rlpf, 0, rlp_buf, byte_len);
- if (rc == 0 && rlpf.ftype == OSMO_RLP_FT_U && rlpf.u_ftype ==
OSMO_RLP_U_FT_NULL)
- return;
- }
-
- arfcn = trx->arfcn;
- if (is_uplink)
- arfcn |= GSMTAP_ARFCN_F_UPLINK;
-
- gsmtap_send_ex(inst, GSMTAP_TYPE_GSM_RLP, arfcn, lchan->ts->nr,
- lchan->type == GSM_LCHAN_TCH_H ? GSMTAP_CHANNEL_VOICE_H :
GSMTAP_CHANNEL_VOICE_F,
- lchan->nr, tch_ind->fn, tch_ind->rssi, 0, rlp_buf, byte_len);
-
-}
-
static void send_ul_rtp_packet_data(struct gsm_lchan *lchan, const struct ph_tch_param
*tch_ind,
const uint8_t *data, uint16_t data_len)
{
@@ -2463,24 +2488,7 @@
msg = l1sap_msgb_alloc(512);
if (!msg)
return;
-
- if (lchan->rsl_cmode == RSL_CMOD_SPD_DATA) {
- int rc = csd_v110_rtp_decode(lchan, msg->tail,
- rtp_pl, rtp_pl_len);
- if (rc > 0) {
- /* 'fake' tch_ind containing all-zero so gsmtap code can be shared
- * between UL and DL */
- static const struct ph_tch_param fake_tch_ind = {};
- gsmtap_csd_rlp_process(lchan, false, &fake_tch_ind, msg->tail, rc);
- msgb_put(msg, rc);
- } else {
- rate_ctr_inc2(bts->ctrs, BTS_CTR_RTP_RX_DROP_V110_DEC);
- msgb_free(msg);
- return;
- }
- } else {
- memcpy(msgb_put(msg, rtp_pl_len), rtp_pl, rtp_pl_len);
- }
+ memcpy(msgb_put(msg, rtp_pl_len), rtp_pl, rtp_pl_len);
msgb_pull(msg, sizeof(struct osmo_phsap_prim));
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bts/+/38312?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Idca6807b1e49b89072683b9f00ff4e7cee44cf33
Gerrit-Change-Number: 38312
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>