Change in osmo-bts[master]: send TCH/F fill frames in DTX mode (WIP)

2018-08-22 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10415 )

Change subject: send TCH/F fill frames in DTX mode (WIP)
..

send TCH/F fill frames in DTX mode (WIP)

Send DTX TCH fill frames according to GSM 05.08, section 8.3.

Change-Id: I7bff00b8cf41dc1b0e6e668173bebce23be0d253
Related: OS#1950
---
M src/common/l1sap.c
1 file changed, 64 insertions(+), 13 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index b8cec0e..5cc303b 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -666,6 +666,31 @@
return 0;
 }

+ /* Determine whether we need to send a DTX TCH fill frame according to GSM 
05.08, section 8.3. */
+static bool is_required_tchf_fill_frame_dtx(uint32_t fn, struct gsm_time 
*g_time) {
+   /* On TCHF this subset of TDMA frames (mod 104) is always used for 
transmission during DTX: */
+   const int tchf_required_fn_dtx[] = { 52, 53, 54, 55, 56, 57, 58, 59 };
+   /* And the subset of those frames which corresponds to a TCH/F block 
boundary,
+* which is the level at which L1SAP operates: */
+   const int tchf_required_block_fn_dtx[] = { 52, 56 };
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(tchf_required_block_fn_dtx); i++) {
+   if (fn % 104 == tchf_required_block_fn_dtx[i])
+   return true;
+   }
+
+   /* We should only see block-level frame numbers here. Log a warning 
otherwise. */
+   for (i = 0; i < ARRAY_SIZE(tchf_required_fn_dtx); i++) {
+   if (fn % 104 == tchf_required_fn_dtx[i])
+   LOGPGT(DL1P, LOGL_NOTICE, g_time,
+   "Unexpected TCH/F frame number received in RTS.IND "
+   "(not at TCH/F block boundary): %u (mod 104: 
%u)\n", fn, fn % 104);
+   }
+
+   return false;
+}
+
 /* PH-RTS-IND prim received from bts model */
 static int l1sap_ph_rts_ind(struct gsm_bts_trx *trx,
struct osmo_phsap_prim *l1sap, struct ph_data_param *rts_ind)
@@ -725,14 +750,18 @@
si = bts_sysinfo_get(trx->bts, _time);
if (si)
memcpy(p, si, GSM_MACBLOCK_LEN);
-   else
+   else {
memcpy(p, fill_frame, GSM_MACBLOCK_LEN);
+   DEBUGPGT(DL1P, _time, "sending fill frame BCCH 
chan_nr=%d fn=%u\n", chan_nr, fn);
+   }
} else if (!(chan_nr & 0x80)) { /* only TCH/F, TCH/H, SDCCH/4 and 
SDCCH/8 have C5 bit cleared */
+   bool dtxd = false;
lchan = get_active_lchan_by_chan_nr(trx, chan_nr);
if (!lchan) {
LOGPGT(DL1P, LOGL_ERROR, _time, "No lchan for 
PH-RTS.ind (chan_nr=%u)\n", chan_nr);
return 0;
}
+   dtxd = lchan->ts->trx->bts->dtxd;
if (L1SAP_IS_LINK_SACCH(link_id)) {
p = msgb_put(msg, GSM_MACBLOCK_LEN);
/* L1-header, if not set/modified by layer 1 */
@@ -752,20 +781,39 @@
if (si) {
/* The +2 is empty space where the DSP 
inserts the L1 hdr */
memcpy(p + 2, si, GSM_MACBLOCK_LEN - 2);
-   } else
+   } else {
memcpy(p + 2, fill_frame, 
GSM_MACBLOCK_LEN - 2);
-   } else if (L1SAP_IS_CHAN_SDCCH4(chan_nr) || 
L1SAP_IS_CHAN_SDCCH8(chan_nr) ||
-  (lchan->rsl_cmode == RSL_CMOD_SPD_SIGN && 
!lchan->ts->trx->bts->dtxd)) {
-   /*
-* SDCCH or TCH in signalling mode without DTX.
-*
-* Send fill frame according to GSM 05.08, 
section 8.3: "On the SDCCH and on the
-* half rate speech traffic channel in 
signalling only mode DTX is not allowed.
-* In these cases and during signalling on the 
TCH when DTX is not used, the same
-* L2 fill frame shall be transmitted in case 
there is nothing else to transmit."
-*/
+   DEBUGPGT(DL1P, _time, "sending fill 
frame SACCH chan_nr=%d fn=%u dtx=%s\n", chan_nr, fn, dtxd ? "enabled" : 
"disabled");
+   }
+   } else if (L1SAP_IS_CHAN_SDCCH4(chan_nr) || 
L1SAP_IS_CHAN_SDCCH8(chan_nr)) {
p = msgb_put(msg, GSM_MACBLOCK_LEN);
memcpy(p, fill_frame, GSM_MACBLOCK_LEN);
+   DEBUGPGT(DL1P, _time, "sending fill frame 
SDCCH 

Change in osmo-bts[master]: send TCH/F fill frames in DTX mode (WIP)

2018-08-22 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10415 )

Change subject: send TCH/F fill frames in DTX mode (WIP)
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/10415
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I7bff00b8cf41dc1b0e6e668173bebce23be0d253
Gerrit-Change-Number: 10415
Gerrit-PatchSet: 2
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Comment-Date: Wed, 22 Aug 2018 19:50:26 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-bts[master]: send TCH/F fill frames in DTX mode (WIP)

2018-08-15 Thread Stefan Sperling
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/10415

to look at the new patch set (#2).

Change subject: send TCH/F fill frames in DTX mode (WIP)
..

send TCH/F fill frames in DTX mode (WIP)

Send DTX TCH fill frames according to GSM 05.08, section 8.3.

Change-Id: I7bff00b8cf41dc1b0e6e668173bebce23be0d253
Related: OS#1950
---
M src/common/l1sap.c
1 file changed, 64 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/15/10415/2
--
To view, visit https://gerrit.osmocom.org/10415
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I7bff00b8cf41dc1b0e6e668173bebce23be0d253
Gerrit-Change-Number: 10415
Gerrit-PatchSet: 2
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-CC: Harald Welte 


Change in osmo-bts[master]: send TCH/F fill frames in DTX mode (WIP)

2018-08-10 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10415 )

Change subject: send TCH/F fill frames in DTX mode (WIP)
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/10415/1/src/common/l1sap.c
File src/common/l1sap.c:

https://gerrit.osmocom.org/#/c/10415/1/src/common/l1sap.c@676
PS1, Line 676: 52, 53, 54, 55, 56, 57, 58, 59
again also here: We are opearating at _block_ level at the l1sap level, not a 
burst level.  So we will ever only see a RTS.ind for 52 and 56 here, and the 
PHY will transmit at fn%26 == (52.53,54,55 and 56,57,58,59 respectively).

So if you want to be super careful, I would check if it's 52 or 56, and could 
OSMO_ASSERT if it's ever any of the other numbers above, which should never 
happen, as TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26), 
which means
0,4,8,13,17,21,
26,30,34,38,47,
52,56,60,65,73,
78,82,86,91,99



--
To view, visit https://gerrit.osmocom.org/10415
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I7bff00b8cf41dc1b0e6e668173bebce23be0d253
Gerrit-Change-Number: 10415
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-CC: Harald Welte 
Gerrit-Comment-Date: Fri, 10 Aug 2018 07:19:38 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in osmo-bts[master]: send TCH/F fill frames in DTX mode (WIP)

2018-08-10 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10415 )

Change subject: send TCH/F fill frames in DTX mode (WIP)
..


Patch Set 1:

are you sure that unexpected frame was received on the TCH/F you ar=e 
monitoring and not on some completely other logical channel?  The 
0303012b2b2b... frames are sent in many places on all kinds of logical channels 
whenever there's nothing else to send, such as downlink AGCH, unused frames in 
SDCCH, ...


--
To view, visit https://gerrit.osmocom.org/10415
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I7bff00b8cf41dc1b0e6e668173bebce23be0d253
Gerrit-Change-Number: 10415
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-CC: Harald Welte 
Gerrit-Comment-Date: Fri, 10 Aug 2018 06:59:34 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in osmo-bts[master]: send TCH/F fill frames in DTX mode (WIP)

2018-08-09 Thread Stefan Sperling
Stefan Sperling has posted comments on this change. ( 
https://gerrit.osmocom.org/10415 )

Change subject: send TCH/F fill frames in DTX mode (WIP)
..


Patch Set 1:

Specifically, this is what I am seeing:

osmo-bts: l1sap.c:793 000260/00/00/05/04 sending fill frame TCH chan_nr=9 
fn=260 dtx=enabled

ttcn3 test: Received DTX TCH fill frame with bad frame number: 268 (mod 104: 60)


--
To view, visit https://gerrit.osmocom.org/10415
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I7bff00b8cf41dc1b0e6e668173bebce23be0d253
Gerrit-Change-Number: 10415
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Comment-Date: Thu, 09 Aug 2018 18:28:24 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in osmo-bts[master]: send TCH/F fill frames in DTX mode (WIP)

2018-08-09 Thread Stefan Sperling
Stefan Sperling has posted comments on this change. ( 
https://gerrit.osmocom.org/10415 )

Change subject: send TCH/F fill frames in DTX mode (WIP)
..


Patch Set 1:

This is WIP because the TTCN3 test TC_tch_sign_l2_fill_frame_dtxd is still 
failing with this diff.

I don't understand the reason for the failure.

The problem is that the TCH/F fill frame is received by the TTCN3 test in a 
frame number which is not in the set of required frame numbers % 104.
Hence the test fails with verdict "Unexpected L2 fill frame received on Um".

However, debug log which is written by this patch shows that the frame number 
used in my osmo-bts patch falls into the set of required frame numbers % 104.

Does anyone have an idea where this problem could be coming from?
Am I wrong in assuming that the frame number used in osmo-bts's 
l1sap_ph_rts_ind() should match the frame number received in TTCN3?


--
To view, visit https://gerrit.osmocom.org/10415
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I7bff00b8cf41dc1b0e6e668173bebce23be0d253
Gerrit-Change-Number: 10415
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Comment-Date: Thu, 09 Aug 2018 18:20:57 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in osmo-bts[master]: send TCH/F fill frames in DTX mode (WIP)

2018-08-09 Thread Stefan Sperling
Stefan Sperling has uploaded this change for review. ( 
https://gerrit.osmocom.org/10415


Change subject: send TCH/F fill frames in DTX mode (WIP)
..

send TCH/F fill frames in DTX mode (WIP)

Send DTX TCH fill frames according to GSM 05.08, section 8.3.

Change-Id: I7bff00b8cf41dc1b0e6e668173bebce23be0d253
Related: OS#1950
---
M src/common/l1sap.c
1 file changed, 52 insertions(+), 13 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/15/10415/1

diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 8d735e5..ed818cb 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -670,6 +670,19 @@
return 0;
 }

+ /* Determine whether we need to send a DTX TCH fill frame according to GSM 
05.08, section 8.3. */
+static bool is_required_tchf_fill_frame_dtx(uint32_t fn) {
+   /* On TCHF this subset of TDMA frames (mod 104) is always used for 
transmission during DTX: */
+   const int tchf_required_fn_dtx[] = { 52, 53, 54, 55, 56, 57, 58, 59 };
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(tchf_required_fn_dtx); i++) {
+   if (fn % 104 == tchf_required_fn_dtx[i])
+   return true;
+   }
+   return false;
+}
+
 /* PH-RTS-IND prim received from bts model */
 static int l1sap_ph_rts_ind(struct gsm_bts_trx *trx,
struct osmo_phsap_prim *l1sap, struct ph_data_param *rts_ind)
@@ -729,14 +742,18 @@
si = bts_sysinfo_get(trx->bts, _time);
if (si)
memcpy(p, si, GSM_MACBLOCK_LEN);
-   else
+   else {
memcpy(p, fill_frame, GSM_MACBLOCK_LEN);
+   DEBUGPGT(DL1P, _time, "sending fill frame BCCH 
chan_nr=%d fn=%u\n", chan_nr, fn);
+   }
} else if (!(chan_nr & 0x80)) { /* only TCH/F, TCH/H, SDCCH/4 and 
SDCCH/8 have C5 bit cleared */
+   bool dtxd = false;
lchan = get_active_lchan_by_chan_nr(trx, chan_nr);
if (!lchan) {
LOGPGT(DL1P, LOGL_ERROR, _time, "No lchan for 
PH-RTS.ind (chan_nr=%u)\n", chan_nr);
return 0;
}
+   dtxd = lchan->ts->trx->bts->dtxd;
if (L1SAP_IS_LINK_SACCH(link_id)) {
p = msgb_put(msg, GSM_MACBLOCK_LEN);
/* L1-header, if not set/modified by layer 1 */
@@ -756,20 +773,39 @@
if (si) {
/* The +2 is empty space where the DSP 
inserts the L1 hdr */
memcpy(p + 2, si, GSM_MACBLOCK_LEN - 2);
-   } else
+   } else {
memcpy(p + 2, fill_frame, 
GSM_MACBLOCK_LEN - 2);
-   } else if (L1SAP_IS_CHAN_SDCCH4(chan_nr) || 
L1SAP_IS_CHAN_SDCCH8(chan_nr) ||
-  (lchan->rsl_cmode == RSL_CMOD_SPD_SIGN && 
!lchan->ts->trx->bts->dtxd)) {
-   /*
-* SDCCH or TCH in signalling mode without DTX.
-*
-* Send fill frame according to GSM 05.08, 
section 8.3: "On the SDCCH and on the
-* half rate speech traffic channel in 
signalling only mode DTX is not allowed.
-* In these cases and during signalling on the 
TCH when DTX is not used, the same
-* L2 fill frame shall be transmitted in case 
there is nothing else to transmit."
-*/
+   DEBUGPGT(DL1P, _time, "sending fill 
frame SACCH chan_nr=%d fn=%u dtx=%s\n", chan_nr, fn, dtxd ? "enabled" : 
"disabled");
+   }
+   } else if (L1SAP_IS_CHAN_SDCCH4(chan_nr) || 
L1SAP_IS_CHAN_SDCCH8(chan_nr)) {
p = msgb_put(msg, GSM_MACBLOCK_LEN);
memcpy(p, fill_frame, GSM_MACBLOCK_LEN);
+   DEBUGPGT(DL1P, _time, "sending fill frame 
SDCCH chan_nr=%d fn=%u dtx=%s\n", chan_nr, fn, dtxd ? "enabled" : "disabled");
+   } else if (lchan->rsl_cmode == RSL_CMOD_SPD_SIGN) {
+   if (lchan->ts->trx->bts->dtxd) {
+   /*
+* TCH in signalling mode with DTX.
+* Send fill frame according to GSM 
05.08, section 8.3.
+*/
+   if (L1SAP_IS_CHAN_TCHF(chan_nr) && 
is_required_tchf_fill_frame_dtx(fn)) {
+   p = msgb_put(msg, 
GSM_MACBLOCK_LEN);
+