falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/38556?usp=email )
Change subject: csd_v110_rtp_decode: preserve E2 & E3 bits for RLP alignment ......................................................................
csd_v110_rtp_decode: preserve E2 & E3 bits for RLP alignment
Modify CSD RTP input path code so incoming bits E2 & E3 from V.110 frames reach the TCH-RTS.ind handler in l1sap. These bits will be used in the next patch to ensure proper alignment of DL RLP frames in non-transparent CSD modes.
Related: OS#6579 Change-Id: I43b97caa6030b9401779998ca5dddc4cfe636e2f --- M include/osmo-bts/csd_v110.h M include/osmo-bts/msg_utils.h M src/common/csd_v110.c M src/common/l1sap.c M tests/csd/csd_test.c 5 files changed, 17 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/56/38556/1
diff --git a/include/osmo-bts/csd_v110.h b/include/osmo-bts/csd_v110.h index 0fcb852..f5c2658 100644 --- a/include/osmo-bts/csd_v110.h +++ b/include/osmo-bts/csd_v110.h @@ -17,4 +17,4 @@ const uint8_t *data, size_t data_len, uint8_t nt48_half_num); int csd_v110_rtp_decode(const struct gsm_lchan *lchan, uint8_t *data, - const uint8_t *rtp, size_t rtp_len); + uint8_t *align_bits, const uint8_t *rtp, size_t rtp_len); diff --git a/include/osmo-bts/msg_utils.h b/include/osmo-bts/msg_utils.h index fb8e11a..db7142d 100644 --- a/include/osmo-bts/msg_utils.h +++ b/include/osmo-bts/msg_utils.h @@ -25,6 +25,9 @@ /* Access 4th part of msgb control buffer */ #define rtpmsg_is_rfc5993_sid(x) ((x)->cb[3])
+/* Access 5th part of msgb control buffer */ +#define rtpmsg_csd_align_bits(x) ((x)->cb[4]) + /** * Classification of OML message. ETSI for plain GSM 12.21 * messages and IPA/Osmo for manufacturer messages. diff --git a/src/common/csd_v110.c b/src/common/csd_v110.c index edd051e..80cc345 100644 --- a/src/common/csd_v110.c +++ b/src/common/csd_v110.c @@ -167,10 +167,11 @@ }
int csd_v110_rtp_decode(const struct gsm_lchan *lchan, uint8_t *data, - const uint8_t *rtp, size_t rtp_len) + uint8_t *align_bits, const uint8_t *rtp, size_t rtp_len) { const struct csd_v110_lchan_desc *desc; ubit_t ra_bits[80 * 4]; + uint8_t align_accum = 0;
OSMO_ASSERT(lchan->tch_mode < ARRAY_SIZE(csd_v110_lchan_desc)); desc = &csd_v110_lchan_desc[lchan->tch_mode]; @@ -208,7 +209,13 @@ osmo_csd_12k_6k_encode_frame(&data[i * 60], 60, &df); else /* desc->num_bits == 36 */ osmo_csd_3k6_encode_frame(&data[i * 36], 36, &df); + /* save bits E2 & E3 that may be needed for RLP alignment */ + align_accum <<= 2; + align_accum |= df.e_bits[1] << 1; + align_accum |= df.e_bits[2] << 0; }
+ if (align_bits) + *align_bits = align_accum; return desc->num_blocks * desc->num_bits; } diff --git a/src/common/l1sap.c b/src/common/l1sap.c index 8bcb241..793b7a8 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -2607,6 +2607,7 @@ struct gsm_bts *bts = lchan->ts->trx->bts; struct msgb *msg; bool rfc5993_sid = false; + uint8_t csd_align_bits = 0;
rate_ctr_inc2(bts->ctrs, BTS_CTR_RTP_RX_TOTAL); if (marker) @@ -2641,7 +2642,7 @@ return;
if (lchan->rsl_cmode == RSL_CMOD_SPD_DATA) { - int rc = csd_v110_rtp_decode(lchan, msg->tail, + int rc = csd_v110_rtp_decode(lchan, msg->tail, &csd_align_bits, rtp_pl, rtp_pl_len); if (rc > 0) { /* 'fake' tch_ind containing all-zero so gsmtap code can be shared @@ -2674,6 +2675,8 @@ rtpmsg_ts(msg) = timestamp; /* Store RFC 5993 SID flag likewise */ rtpmsg_is_rfc5993_sid(msg) = rfc5993_sid; + /* ditto with CSD alignment bits */ + rtpmsg_csd_align_bits(msg) = csd_align_bits;
/* make sure the queue doesn't get too long */ lchan_dl_tch_queue_enqueue(lchan, msg, 1); diff --git a/tests/csd/csd_test.c b/tests/csd/csd_test.c index 15ee84f..e52bde2 100644 --- a/tests/csd/csd_test.c +++ b/tests/csd/csd_test.c @@ -133,7 +133,7 @@ fprintf(stderr, " %s\n", osmo_hexdump(&rtp[i * 16], 16));
/* decode the encoded RTP frame */ - rc = csd_v110_rtp_decode(&lchan, &data_dec[0], &rtp[0], sizeof(rtp)); + rc = csd_v110_rtp_decode(&lchan, &data_dec[0], NULL, &rtp[0], sizeof(rtp)); fprintf(stderr, "[i] csd_v110_rtp_decode() returns %d\n", rc); if (rc != bit_num) return;